, , ,

Export of regression tables to LaTeX

The ado-files –esto– and —esta— (has to be installed by typing –findit esto– or —findit esta— into the Stata command window) provides a simple way to export regression tables from Stata to a separate LaTeX-file. At the same time, it is possible to adjust basically everything. I will just present a short example that I…

The ado-files --esto-- and —esta— (has to be installed by typing --findit esto-- or —findit esta— into the Stata command window) provides a simple way to export regression tables from Stata to a separate LaTeX-file. At the same time, it is possible to adjust basically everything. I will just present a short example that I use for my regression tables (for adjusting the code, see --help esta--). After installing the ado-packages, run (in this case) two regressions, in my case:
xtreg l_att abstenure abstenure_2 sl_time, fe
esto model1

xtreg l_att abstenure abstenure_2 abstenure_3 sl_time, fe
esto model2

esta model1 model2 ///
using "..\papers\productivity\model1a.tex", replace ///
star(* 0.10 ** 0.05 *** 0.01) plain nogaps ///
depvars b(%9.4f) legend noabbrev style(tex) ///
title("Baseline fixed-effects regressions with tenure (all departments)" \label{model1a}) ///
label stats(N N_g r2_o r2 F ll, fmt(%9.0g %9.0f %9.4f %9.4f %9.4f %9.4f ) ///
labels(Observations "No. of individuals" Overall-R$^2$ R$^2$ F-test "log(likelihood)")) se ///
order(tenure tenure_2 tenure_3 sl_time abstenure) ///
addnotes("Standard errors in parentheses") ///
numbers lines parentheses nolz ///
substitute(\begin{table}[htbp]\centering \begin{table}[htbp]\centering\footnotesize{ \end{tabular} \end{tabular}})

That’s how it looks in my case in the end:

Regression table done with esta/esto

 

Just shortly, I will describe the most important options (for further reading, check the helpfile):

  • using “…”: defines where to save the .tex-file (note: to navigate upwards in the folder sytem, use ../folder/”
  • style(tex): defines that the output should be latex and no other format
  • title(“XXX”): defines the title of the table
  • \label{model1a}): can be used to refer to the table from the text in the  latex-file
  • stats(N N_g r2_o r2 F ll, fmt(%9.0g %9.0f %9.4f %9.4f %9.4f %9.4f ): defines which auxiliary statistics should be shown and how they should be formatted (all stored statistics can be used; check  –search estat–)
  • labels(Observations “No. of individuals” Overall-R$^2$ R$^2$ F-test “log(likelihood)”)): defines the labels according
  • se: defines that you get SE instead of t or p values
  • order(tenure tenure_2 tenure_3 sl_time abstenure): here, you can specify the order of the variables shown in the output
  • addnotes(“Standard errors in parentheses”): add notes to the bottom of the paper 
  • substitute(\begin{table}[htbp]\centering \begin{table}[htbp]\centering\footnotesize{ \end{tabular} \end{tabular}}): I use this cryptic code for specifying that I want the table shown in  footnotesize.
  • noabbrev: do not abbreviate the variable names

Responses to “Export of regression tables to LaTeX”

  1. Jan Sauermann

    A short note: the ado-file –esta/o– is based on –estout–. It is recommended to use –esta– because there are more options available compared to –estout–.

  2. Jeremy L. Wells (@introtoir)

    I suggest using the “wrap” option so that variable labels will wrap to the next line (assuming you print coefficients and SEs/t-stats on another line.

Leave a Reply