sum2docx is now available on SSC, thanks to Prof. Kit Baum.
It makes reporting summary statistics easy to DOCX files, which can be easily appended to other docx files most likely to be generated by Stata 15 new command putdocx.
It can report all the statistics which can be reported by command summarize in detail model. You can specify those statistics as options.
Users can also append the output from sum2docx to other docx documents, which is more likely to be generated by putdocx, reg2docx and ect, either using the
append option or the command can be as following:
putdocx append d:/mytable0.docx d:/mytable1.docx d:/mytable2.docx, saving(d:/mytable.docx,replace)
Example
sysuse auto, clear
Report summary statistics for variable mpg weight length rep78 and foreign
sum2docx mpg weight length rep78 foreign using d:/temp1.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g)
Add table tile
sum2docx mpg weight length rep78 foreign using d:/temp2.docx, replace obs mean sd min median max title("this is the summary statistics")
Add format for summary statistics
sum2docx mpg weight length rep78 foreign using d:/temp3.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("this is the
summary statistics")
Use wild card
sum2docx *n* m?g using d:/temp4.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("Table 1: this is the summary statistics")
Use all variables
drop make
sum2docx _all using d:/temp5.docx, replace obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("Table 1: this is the summary statistics")
Append all files together
putdocx append d:/temp1.docx d:/temp2.docx d:/temp3.docx d:/temp4.docx d:/temp5.docx, saving(d:/mytable.docx,replace)
We can also use the option append to append the output to an existing file
sum2docx mpg weight length rep78 foreign using d:/mytable.docx, append obs mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g) title("this is the
summary statistics")