I have been playing around with the new table and collect commands in Stata 17 as I see the appeal in being able to create customisable and reproducible tables.
I'm wondering if it's possible to create a customisable table within markstat using collect. This works well up to a point, but the moment you apply any cell appearance formatting (e.g. changing table cell margins, changing fonts) this isn't transferred into the word document created by markstat with a simple 'collect preview' command. Cell formatting is applied correctly and retained if you use 'collect export' but this produces a separate word document.
I'm wondering if it's possible to integrate collect with markstat to produce word docs containing inline customisable formatted tables.
I realise this might be a question more for Germán, but if anyone has had a go with this and can provide any tips that would be great.
Some code that I've been experimenting with is below.
Also attached is a markstat file (rejected .stmd so I changed to .txt). markstat_collect.txt
Thanks - Paul
I'm wondering if it's possible to create a customisable table within markstat using collect. This works well up to a point, but the moment you apply any cell appearance formatting (e.g. changing table cell margins, changing fonts) this isn't transferred into the word document created by markstat with a simple 'collect preview' command. Cell formatting is applied correctly and retained if you use 'collect export' but this produces a separate word document.
I'm wondering if it's possible to integrate collect with markstat to produce word docs containing inline customisable formatted tables.
I realise this might be a question more for Germán, but if anyone has had a go with this and can provide any tips that would be great.
Some code that I've been experimenting with is below.
Also attached is a markstat file (rejected .stmd so I changed to .txt). markstat_collect.txt
Thanks - Paul
Code:
sysuse auto collect clear // Now launch Table Builder (Statistics > Summaries, Tables and Tests > Tables and Collections > Build and Style Table) quietly collect _r_b _r_se _r_ci _r_p: regress mpg price c.trunk##i.foreign quietly collect layout (colname) (result) // Set proposed table layout // Note that the Table Builder now populates. Look at Levels within the Result(result) Dimension. These are the results you can display. // In the above I have only selected the coefficient, SE, CI and p value. collect style showbase off // Remove ref cat collect style cell result[_r_b _r_se _r_ci], nformat(%5.2f) // leave 3 decimal places on p value collect style cell result[_r_b _r_se _r_ci _r_p], halign(center) collect label levels result _r_b "beta", modify // Change 'Coefficient' to "beta" collect label levels result _r_se "S.E.", modify // Change 'Std. error' to "S.E." collect label levels result _r_p "p", modify // Change 'p-value' to "p" collect label levels colname trunk "Trunk Space", modify // Remove units from label // Changes to the 'cell appearance style' don't appear in the console or in markstat docs collect style cell, margin(bottom top, width(10)) margin(left right, width(30)) // Increase column width collect style cell, font( garamond, ) // change font collect preview // How to incorporate this directly into word doc using markstat?? // This is how it should look collect export "test.docx", as(docx) replace
Comment