I want to create a report in Stata that includes both the tables and the text descriptions of that table. I know how to use putdocx / esttab to create the summary tables. But I am struggling to understand if it is for example directly possible to "reference" correlations between two variables in putdocx text without having to save them as locals first. I am asking because saving each statistic I would like to report in a local seems inefficient and tedious. I know I could possibly use dyndoc, but I want to know if there is also an option for putdocx.
The standard approach from Chuck Hubers' presentation seems to be:
Based on the Putdocx manual (p. 88), I can see however that we directly plug in stored results from a command into putdocx text. For example:
So, in an ideal world, I would like to directly plug in values from my pwcorr command without having to save them in a local, but using my approach does not work.
webuse auto.dta
The standard approach from Chuck Hubers' presentation seems to be:
Code:
webuse auto.dta pwcorr * matrix correlations = r(C) local cor1 = string(correlations["price", "mpg"]) putdocx begin putdocx paragraph putdocx text ("The correlation between price and mileage is `cor1'") putdocx save Corr1, replace
Code:
summarize price putdocx begin putdocx paragraph putdocx text (" We analyze a dataset with `r(N)' cars,") putdocx save Corr2, replace
webuse auto.dta
Code:
pwcorr * matrix correlations = r(C) putdocx begin putdocx paragraph putdocx text (`correlations["price", "mpg"]'), nformat(%5.2f) putdocx save Corr3 putdocx append Corr1 Corr2 Corr3
Comment