\documentclass[12pt]{article} \newcommand{\bs}{$\backslash$} \thispagestyle{empty} \begin{document} \section{Tabstat in \LaTeX using {\tt latabstat} Command} \subsection{Example 1: Group means of variables} \begin{small} \begin{verbatim} . tabstat math write read, by(female) Summary statistics: mean by categories of: female (Gender) female | math write read -------+------------------------------ male | 52.94505 50.12088 52.82418 female | 52.3945 54.99083 51.73394 -------+------------------------------ Total | 52.645 52.775 52.23 -------------------------------------- . latabstat math write read, by(female) \begin{table}[htbp]\centering \caption{\label{} \textbf{} }\begin{tabular} {@{} l r r r @{}} \\ \hline \textbf{female } & \textbf{ math} & \textbf{ write} & \textbf{ read} \\ \hline male & 52.94505 & 50.12088 & 52.82418 \\ female & 52.3945 & 54.99083 & 51.73394 \\ Total & 52.645 & 52.775 & 52.23 \\ \hline \multicolumn{4}{@{}l}{ \footnotesize{\emph{Source:} http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta}} \end{tabular} \end{table} \end{verbatim} \end{small} \begin{table}[htbp]\centering \caption{\label{} \textbf{} }\begin{tabular} {@{} l r r r @{}} \\ \hline \textbf{female } & \textbf{ math} & \textbf{ write} & \textbf{ read} \\ \hline male & 52.94505 & 50.12088 & 52.82418 \\ female & 52.3945 & 54.99083 & 51.73394 \\ Total & 52.645 & 52.775 & 52.23 \\ \hline \multicolumn{4}{@{}l}{ \footnotesize{\emph{Source:} http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta}} \end{tabular} \end{table} \subsection{Example 2: Requesting more statistics} \begin{small} \begin{verbatim} . tabstat write, by(female) s(mean sd) f(%5.2f) Summary for variables: write by categories of: female female | mean sd -------+-------------------- male | 50.12 10.31 female | 54.99 8.13 -------+-------------------- Total | 52.77 9.48 ---------------------------- . latabstat write, by(female) s(mean sd) f(%5.2f) \begin{table}[htbp]\centering \caption{\label{} \textbf{} }\begin{tabular} {@{} l r r @{}} \\ \hline \textbf{female } & \textbf{ mean} & \textbf{ sd} \\ \hline male & 50.12 & 10.31 \\ female & 54.99 & 8.13 \\ Total & 52.77 & 9.48 \\ \hline \multicolumn{3}{@{}l}{\footnotesize{\emph{Source:} http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta}} \end{tabular} \end{table} \end{verbatim} \end{small} \begin{table}[htbp]\centering \caption{\label{} \textbf{} }\begin{tabular} {@{} l r r @{}} \\ \hline \textbf{female } & \textbf{ mean} & \textbf{ sd} \\ \hline male & 50.12 & 10.31 \\ female & 54.99 & 8.13 \\ Total & 52.77 & 9.48 \\ \hline \multicolumn{3}{@{}l}{\footnotesize{\emph{Source:} http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta}} \end{tabular} \end{table} \subsection{Example 3: Table with a title} The last example table does not have a title. We can use the option {\tt cap} after {\tt latabstat} to make a title for the table. \begin{small} \begin{verbatim} . latabstat math write read, by(female) cap(Scores by Gender) \begin{table}[htbp]\centering \caption{\label{} \textbf{Scores by Gender} }\begin{tabular} {@{} l r r r @{}} \\ \hline \textbf{female } & \textbf{ math} & \textbf{ write} & \textbf{ read} \\ \hline male & 52.94505 & 50.12088 & 52.82418 \\ female & 52.3945 & 54.99083 & 51.73394 \\ Total & 52.645 & 52.775 & 52.23 \\ \hline \multicolumn{4}{@{}l}{ \footnotesize{\emph{Source:} http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta}} \end{tabular} \end{table} \end{verbatim} \end{small} \begin{table}[htbp]\centering \caption{\label{} \textbf{Scores by Gender} }\begin{tabular} {@{} l r r r @{}} \\ \hline \textbf{female } & \textbf{ math} & \textbf{ write} & \textbf{ read} \\ \hline male & 52.94505 & 50.12088 & 52.82418 \\ female & 52.3945 & 54.99083 & 51.73394 \\ Total & 52.645 & 52.775 & 52.23 \\ \hline \multicolumn{4}{@{}l}{ \footnotesize{\emph{Source:} http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta}} \end{tabular} \end{table} \end{document}