Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72764

Using Stata for reproducible, dynamic, publication-quality tables (MarkDoc)

$
0
0
Hello, I am hoping some fellow Statalisters could help me with this issue.

The goal is to create a separate Word document (format required by most medical journals) for each Table in a manuscript directly from a dataset, and to avoid having to transcribe information from the computer screen to the Word document manually. This would allow updating of the Table by simply running the .do file again each time data may have changed/been added/been deleted. Please see the attached for an example of what I'm looking to create.

I have installed the useful MarkDoc package (by haghish ) and I have it working for plain documents. However, I haven't seen an example of how to implement tables using this nomenclature. For instance, if I have event rates in two groups, and I want to present relative risks and 95% CIs of those RRs, do I set a macro with the value of the RR and upper/lower ends of the 95% CI and use Markdown to insert them into a table?

My initial attempt, below, allows me to create a nice-looking document, and the table show up, but I cannot seem to get the `rr' to appear in the table.

Code:
cd "~/Desktop"
     set linesize 90

qui log using example, replace

             /*** 
             Introduction to MarkDoc (heading 1) 
             =================================== 
    
             Using Markdown (heading 2)
             -------------------------- 
    
             Writing with __markdown__ syntax allows you to add text and graphs to
             _smcl_ logfile and export it to a editable document format. I will demonstrate
             the process by using the __Auto.dta__ dataset.

             ###Get started with MarkDoc (heading 3)
             I will open the dataset, list a few observations, and export a graph.
             Then I will export the logfile to Microsoft Office docx format.
             ***/

/**/ sysuse auto, clear 
/**/  list in 1/5               
histogram price
graph export graph.png,  width(400) replace

             /*** 
             Adding a graph or image in the report 
             ====================================== 

             Adding a graph using Markdown
             -----------------------------
    
             In order to add a graph using Markdown, I export the graph in PNG format.
             You can explain the graph in the "brackets" and define the file path in parentheses
             
             ![Figure 1 - A histogram](./graph.png)
             ***/

local rr "RR 3.4"

/***

Tables

| Tables   |      Are      |  Cool |
|----------|:-------------:|------:|
| col 1 is |  left-aligned | $1600 |
| col 2 is |    centered   |   $12 |
| col 3 is | right-aligned |    $1 |
    


|  Tables | Are     | Really  | Cool  |   |
|:-:|:----:|:-:|:-:|:-:|
| s | `rr' |   |   |   |
|   |      |   |   |   |
|   |      |   |   |   |

***/
             
qui log c

markdoc example, replace export(docx)
markdoc example, replace export(pdf)
I would appreciate any help. Thank you,

Phil

Viewing all articles
Browse latest Browse all 72764

Trending Articles