I have multiple sets of regressions that need to be presented in different tables. I wonder if there is a way to export multiple set of regressions into one Excel workbook using either outreg2
or esttab
or some other package?
For example, I run 100 regressions using esttab
; then I want to present them in 25 different tables with four regressions in each table. The following format of code allows me to export to 25 different csv files:
esttab using "$output\output1.csv", se stats(N ymean r2_a) replace
However, I want to have all the 25 tables in one workbook with 25 tabs. It is possible to copy-paste the tables if the number of output files is not big, but that's not the case for me.
The putexcel command exports Stata results to an Excel file. You can easily export a matrix or a table of estimation results. putexcel is also great for exporting multiple sets of results because you can format entire rows and columns, and loop over them. The putdocx and putpdf suites export Stata results to .
outreg can arrange the results of Stata estimation commands in tables as they are typically presented in journal articles, rather than as they are presented in the Stata Results window. By default, t statistics appear in parentheses below the coefficient estimates with asterisks for significance levels.
Copy as image from the results window and paste into Word Highlight the output you want to save, then use the pulldown menu to choose Edit and then Copy as Picture. This is illustrated below. You can then go to Microsoft Word and from its pulldown menu choose Edit then Paste.
With outreg2
, you'll need to use the dta
option to save the results as individual datasets, and then use the export excel
command to export each dataset to an individual sheet in the same tab. E.g.:
clear all
sysuse auto
regress price mpg
outreg2 using "price" , replace dta
regress price mpg headroom
outreg2 using "price" , dta
regress mpg weight length
outreg2 using "mpg" , replace dta
regress mpg weight length foreign
outreg2 using "mpg" , dta
use price_dta
export excel using "results" , sheet("price")
use mpg_dta
export excel using "results" , sheet("mpg")
Obviously running this as a loop will make more sense, and you may want to add the replace
option to the first use of outreg2
. Further use of outreg2
's options will help clean up the output further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With