### Summary Statistics in LaTeX

Command sutex is a companion for command summarize in Stata. It generates LaTeX code for summary statistics tables. The command is not built-in Stata commands. You can use Stata's findit command to download the program from the internet. Please see our webpage on how to use findit to search for programs and additional help for more details.

Example 1: Summarizing every variable in the data set

use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear
(highschool and beyond (200 cases))
. summarize
    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
id |       200       100.5    57.87918          1        200
female |       200        .545    .4992205          0          1
race |       200        3.43    1.039472          1          4
ses |       200       2.055    .7242914          1          3
schtyp |       200        1.16     .367526          1          2
-------------+--------------------------------------------------------
prog |       200       2.025    .6904772          1          3
read |       200       52.23    10.25294         28         76
write |       200      52.775    9.478586         31         67
math |       200      52.645    9.368448         33         75
science |       200       51.85    9.900891         26         74
-------------+--------------------------------------------------------
socst |       200      52.405    10.73579         26         71
sutex
%------- Begin LaTeX code -------%
\begin{table}[htbp]\centering \caption{Summary statistics \label{sumstat}}
\begin{tabular}{l c c  }\hline\hline
\multicolumn{1}{c}{\textbf{Variable}} & \textbf{Mean}
& \textbf{Std. Dev.} \\ \hline
id & 100.5 & 57.879  \\
female & 0.545 & 0.499  \\
race & 3.43 & 1.039  \\
ses & 2.055 & 0.724  \\
schtyp & 1.16 & 0.368  \\
prog & 2.025 & 0.690  \\
read & 52.23 & 10.253  \\
write & 52.775 & 9.479  \\
math & 52.645 & 9.368  \\
science & 51.85 & 9.901  \\
socst & 52.405 & 10.736  \\
\multicolumn{1}{c}{N} & \multicolumn{2}{c}{200}\\ \hline
\end{tabular}
\end{table}
%------- End LaTeX code -------%

We can then copy the code above to a LaTeX file and compile it. Here is the pdf file showing the table.

Example 2: Requesting min and max of variables to be displayed

The default for command sutex is to display only the mean and standard deviation for each of the variables. We can request to have both the min and max for each of the variables to be displayed by using the minmax option. Here is an example of it.

sutex , minmax
%------- Begin LaTeX code -------%
\begin{table}[htbp]\centering \caption{Summary statistics \label{sumstat}}
\begin{tabular}{l c c c c }\hline\hline
\multicolumn{1}{c}{\textbf{Variable}} & \textbf{Mean}
& \textbf{Std. Dev.}& \textbf{Min.} &  \textbf{Max.} \\ \hline
id & 100.5 & 57.879 & 1 & 200 \\
female & 0.545 & 0.499 & 0 & 1 \\
race & 3.43 & 1.039 & 1 & 4 \\
ses & 2.055 & 0.724 & 1 & 3 \\
schtyp & 1.16 & 0.368 & 1 & 2 \\
prog & 2.025 & 0.690 & 1 & 3 \\
read & 52.23 & 10.253 & 28 & 76 \\
write & 52.775 & 9.479 & 31 & 67 \\
math & 52.645 & 9.368 & 33 & 75 \\
science & 51.85 & 9.901 & 26 & 74 \\
socst & 52.405 & 10.736 & 26 & 71 \\
\multicolumn{1}{c}{N} & \multicolumn{4}{c}{200}\\ \hline
\end{tabular}
\end{table}
%------- End LaTeX code -------%

We can then copy the code above to a LaTeX file and compile it. Here is the pdf file showing the table.

We can also put all the examples above together in one single LaTeX file and here is the pdf file corresponding to it.

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.