The ado-file --sutex--
(has to be installed by typing --findit sutex--
into the Stata command window) provides a simple way to export summary statistics from Stata to a separate LaTeX-file. It is limited in individualised adjustment, but quite OK for most applications. By default, you get mean and standard deviation for variables VAR1, VAR2, VAR3
, etc. A syntax could be:
sutex VAR1 VAR2 VAR3, lab nobs key(descstat) replace ///
file(descstat.tex) title("Summary statistics") minmax
with the following options included:
— lab
(use labels instead of variable names)
— nobs
(add number of observations
— key(STRING)
(add a key to the table so that you can reference from the text by typing \ref{STRING}
in the LaTeX file)
— file(STRING)
(generates a new .tex-file)
— title("STRING")
(adds a title to the table)
— minmax
(adds minimum and maximum)
— replace
(replaces the old file when there was a new run)
The new .tex-file (here: descstat.tex
) can be easily included into another .tex-file by using the LaTeX-command: \input{descstat}
Alternative (manual) way:
quietly: tabstat VARLIST, c(s) stat(mean) save
matrix output = r(StatTotal)'
quietly: tabstat `desc', c(s) stat(sd) save
matrix output = output,r(StatTotal)'
outtable using TEXFILENAME, mat(output) center replace ///
caption("TITLE") nobox f(%12.2fc) label ///
clabel(descstat)
NOTE: before using this alternative approach, you have to install the ado-file —outtable
–. In the field --stat(mean)--
you can enter any statistic generated by stata (count, sd, min, max etc)
Leave a Reply
You must be logged in to post a comment.