I want to be able to report some numbers from a summary table in text using putdocx. My preferred command is the dtable command since it contains both summary statistics by groups and the associated tests for both continuous and categorical variables. I read the manual, and used return list and ereturn list to see if dtable returns a matrix I could use, but to no avail. The dtable manual describes how to use the collect command can see that collect preview I want to save the results from dtable to a matrix. I also tried to find if I can save a collection to a matrix, but I also had no luck finding a solution.
The Word-Document should then contain: "In total our dataset features 52 domestic and 22 foreign cars."
Code:
sysuse auto dtable mpg, by(foreign) collect label list result matrix summary = ? putdocx begin putdocx paragraph putdocx text ("In total our dataset features `:di %5.0f `=matrix["N", "Domestic"]' domestic and `:di %5.0f `=matrix["N", "Foreign"]' foreign cars.") putdocx save Sample.docx
Comment