这个很简单啊,不就是做个均值,标准差的输出表格吗,sum2docx就可以实现,然后调整一下就行
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
stats(N mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g))
Add table title
sum2docx mpg weight length rep78 foreign using d:/temp2.docx, replace
stats(N mean sd min median max) title("this is the summary
statistics")
Add notes
sum2docx mpg weight length rep78 foreign using d:/temp3.docx, replace
stats(N mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g))
title("this is the summary statistics") note("Data source: auto.dta")
Use wild card
sum2docx *n* m?g using d:/temp4.docx, replace stats(N 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 stats(N 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
stats(N mean(%9.2f) sd min(%9.0g) median(%9.0g) max(%9.0g))
title("this is the summary statistics")
|