Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 36 ยท Reproducible Reporting

Regression Tables with estimates, estout and esttab

Store models with estimates store and build publication-ready regression tables in Stata using esttab, estout, table and collect, exporting to Word, LaTeX or CSV.

Results that live only in the Results window are not reproducible, and copying numbers by hand into a paper is where typos are born. Stata has a clear path from a fitted model to a finished table: store the estimates, ask a table command to arrange them in columns, and write the result to a file that Word, LaTeX or a spreadsheet can open. When you re-run the do-file, the table updates itself.

Stata cannot run here, so commands are read-only. The runnable blocks are Python stand-ins that format a small regression table with stars and standard errors the way esttab does, so you can see what each option changes. The numbers are simulated.

Storing estimates

STATA
sysuse auto, clear
regress price mpg
estimates store m1
regress price mpg weight
estimates store m2
regress price mpg weight i.foreign
estimates store m3
estimates table m1 m2 m3, b(%9.2f) se stats(N r2)

estimates store name saves everything about the last model in memory (not on disk). estimates table is built in and gives a quick side-by-side comparison. estimates save and estimates use write models to disk. Remember that models must be fitted on the same sample for a comparison to be fair; see the e(sample) tip in the regress lesson.

esttab and estout

estout and its simpler wrapper esttab are community commands from SSC. Install once:

STATA
ssc install estout, replace

Then:

STATA
esttab m1 m2 m3, ///
    b(3) se(3) ///
    star(* 0.10 ** 0.05 *** 0.01) ///
    stats(N r2 r2_a, labels("Observations" "R-squared" "Adj. R-squared")) ///
    label ///
    title("Determinants of car prices") ///
    mtitles("Mileage" "+ Weight" "+ Origin")

Frequently used options:

Option Effect
b(3), se(3) Three decimals for coefficients and standard errors
t, p, ci Show t statistics, p-values or intervals instead of se
star(...) Significance stars and thresholds; nostar removes them
keep() / drop() Show only the listed coefficients
order() Reorder rows
label Use variable labels instead of names
indicate("Region FE = *region*") Replace many dummy rows with a Yes/No row
mtitles(), mgroups() Column titles and column groups
addnotes() Add table notes (for example about clustering)
r2, ar2, aic, bic, scalars() Fit statistics

Exporting

The same command writes to files by changing the extension or format option:

STATA
esttab m1 m2 m3 using "output/tables/prices.rtf", replace   // Word-readable
esttab m1 m2 m3 using "output/tables/prices.tex", replace booktabs  // LaTeX
esttab m1 m2 m3 using "output/tables/prices.csv", replace csv       // spreadsheet
esttab m1 m2 m3 using "output/tables/prices.md", replace md         // Markdown

Use replace so that re-running overwrites the old file, and keep outputs in an output folder separate from the code, as suggested in the do-file layout. In LaTeX, booktabs gives professional rules; in Word, open the .rtf and use Insert > Table style as you like.

Summary statistics and balance tables

STATA
ssc install estout
estpost summarize price mpg weight, detail
esttab using "output/tables/summary.rtf", cells("mean sd min max") nonumber replace

estpost ttest price mpg weight, by(foreign)
esttab, cells("mu_1 mu_2 b(star)") 

estpost turns the results of descriptive commands into estimates so esttab can format them. The built-in table command (Stata 17+ with collect) can also create customizable tables and export them with collect export; it is the official alternative when you cannot install packages. Similar user-written options include outreg2 and modelsummary-style tools in other languages.

Stand-in: a formatted regression table

This block simulates three nested models and prints a table like esttab: coefficient with significance stars, standard errors in parentheses, and a fit-statistics footer.

Python An esttab-like table (Python stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Because mpg and weight are correlated in this simulation, the mpg coefficient changes when weight is added. A side-by-side table makes that kind of sensitivity visible, which is why this is the standard way to present regression results.

Writing a table to a file by hand

Behind esttab using is plain text output. The stand-in below shows how the same rows would be written as Markdown or CSV, which is what the md and csv options do.

Python Writing the table as CSV (Python stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Style and honesty

  • Put standard errors in parentheses and say so in a note; say what the stars mean.
  • Report the clustering level and the estimator in the notes (addnotes("Standard errors clustered by state.")).
  • Do not hide models you tried; use drop() only for nuisance rows such as dozens of dummies, and say so with indicate.
  • Use consistent decimals, and avoid false precision.

For writing Word and Excel documents directly, see exporting results.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does estimates store m1 do?

    It stores the estimates in memory for the session; estimates save writes them to disk.
  2. 2. Which package provides esttab?

    esttab is a wrapper of estout; install with ssc install estout.
  3. 3. What does the replace option do in esttab using file, replace?

    Without replace, Stata refuses to overwrite an existing file.
  4. 4. How can you show a Yes/No row instead of many dummy rows?

    indicate() collapses groups of coefficients into a single indicator row.

Summary

  • Store each model with estimates store, compare with estimates table.
  • esttab/estout build tables with stars, standard errors, fit statistics and export to RTF, LaTeX, CSV or Markdown.
  • estpost handles descriptive tables; collect is the built-in alternative.
  • The Python blocks are stand-ins for formatting.

Next: Exporting results to Excel and Word