Using outreg2 to report regression
output, descriptive statistics, frequencies
and basic crosstabulations
(v1.6 draft)
Oscar Torres-Reyna
otorres@[Link]
March 2014 [Link]
Linear regression
The command outreg2 gives you the type of presentation you see in academic papers. It is important to notice that outreg2
is not a Stata command, it is a user-written procedure, and you need to install it by typing (only the first time)
ssc install outreg2
Follow this example (letters in italics you type)
use "[Link] clear
reg y x1, robust
outreg2 using [Link], replace ctitle(Model 1)
. outreg2 using [Link], replace ctitle(Model 1)
[Link]
Windows users click here to open the file [Link] in Word (you
dir : seeout
can replace this name with your own) . Otherwise follow the Mac
instructions.
Mac users click here to go to the directory where [Link] is saved, open it with Word
(you can replace this name with your own)
You can add other model (using variable x2) by using the option append
(NOTE: make sure to close [Link])
reg y x1 x2, robust
outreg2 using [Link], append ctitle(Model 2)
. outreg2 using [Link], append ctitle(Model 2)
[Link]
dir : seeout
You also have the option to export to Excel, just use the extension *.xls.
For older versions of outreg2, you may need to specify the option word or excel (after comma)
OTR Source: Updated version shown here [Link]
PU/DSS/OTR
Linear regression: showing variable labels instead of variable names
The command outreg2 gives you the type of presentation you see in academic papers. It is important to notice that outreg2
is not a Stata command, it is a user-written procedure, and you need to install it by typing (only the first time)
ssc install outreg2
Follow this example (letters in italics you type)
use "[Link] clear
reg y x1, robust
outreg2 using [Link], replace ctitle(Model 1) label
. outreg2 using [Link], replace ctitle(Model 1)
[Link]
Windows users click here to open the file [Link] in Word (you
dir : seeout
can replace this name with your own) . Otherwise follow the Mac
instructions.
Mac users click here to go to the directory where [Link] is saved, open it with Word
(you can replace this name with your own)
You can add other model (using variable x2) by using the option append
(NOTE: make sure to close [Link])
reg y x1 x2, robust
outreg2 using [Link], append ctitle(Model 2) label
. outreg2 using [Link], append ctitle(Model 2)
[Link]
dir : seeout
You also have the option to export to Excel, just use the extension *.xls.
For older versions of outreg2, you may need to specify the option word or excel (after comma)
NOTE: Other options for label: label(insert); label(proper); label(upper); label(lower)
OTR
Source: Updated version of [Link]
PU/DSS/OTR
Fixed effects regression
Letters in italics you type
use "[Link] clear
xtreg y x1 x2 x3, fe robust
outreg2 using [Link], replace ctitle(Fixed Effects) addtext(Country FE, YES)
. outreg2 using [Link], replace ctitle(Fixed Effects) addtext(Country FE, YES)
[Link]
Windows users click here to open the file [Link] in Word (you
dir : seeout
can replace this name with your own) . Otherwise follow the Mac
instructions.
Mac users click here to go to the directory where [Link] is saved, open it with Word (you can
replace this name with your own)
You also have the option to export to Excel, just use the extension *.xls.
For older versions of outreg2, you may need to specify the option word or excel (after comma)
In fixed effects models you do not have to add the FE coefficients,
you can just add a note indicating that the model includes fixed
effects. This can be added from outreg2, see the option
addtex() above.
OTR Fro more info on panel data regression see [Link]
PU/DSS/OTR
Fixed effects with time fixed effects
Letters in italics you type
use "[Link] clear
xtreg y x1 x2 x3 [Link], fe robust
outreg2 using [Link], replace ctitle(Fixed Effects) keep(x1 x2 x3) addtext(Country FE, YES, Year FE, YES)
. outreg2 using [Link], replace ctitle(Fixed Effects) addtext(Country FE, YES)
[Link]
Windows users click here to open the file [Link] in Word (you
dir : seeout
can replace this name with your own) . Otherwise follow the Mac
instructions.
Mac users click here to go to the directory where [Link] is saved, open it with Word (you can
replace this name with your own)
You also have the option to export to Excel, just use the extension *.xls.
For older versions of outreg2, you may need to specify the option word or excel (after comma)
In fixed effects models you do not have to add the FE coefficients,
you can just add a note indicating that the model includes fixed
effects. This can be added from outreg2, see the option
addtex() above.
OTR Fro more info on panel data regression see [Link]
PU/DSS/OTR
Comparing different linear models
Letters in italics you type
use "[Link] clear
xtset country year
reg y x1 x2 x3, robust
outreg2 using [Link], replace ctitle(OLS)
xtreg y x1 x2 x3, fe robust
outreg2 using [Link], append ctitle(Fixed Effects) addtext(Country FE, YES)
xtreg y x1 x2 x3 [Link], fe robust
outreg2 using [Link], append ctitle(Fixed Effects) keep(x1 x2 x3) addtext(Country FE, YES, Year FE, YES)
. outreg2 using [Link], append ctitle(Fixed Effects) keep(x1 x2 x3) addtext(Country FE, Y
> ES, Year FE, YES)
[Link]
dir : seeout Windows users click here to open the file
[Link] in Word (you can replace this
name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link]
is saved, open it with Word (you can replace this name with
your own)
OTR Fro more info on panel data regression see [Link]
PU/DSS/OTR
Regression: publishing logit/probit output (outreg2)
You can use outreg2 for almost any regression output (linear or no linear). In the case of logit models with odds ratios, you
need to add the option eform, see below
use "[Link] clear
logit y_bin x1
outreg2 using [Link], replace ctitle(Logit coeff)
. outreg2 using [Link], replace ctitle(Logit coeff)
[Link]
dir : seeout
logit y_bin x1, or
outreg2 using [Link], append ctitle(Odds ratio) eform
. outreg2 using [Link], append ctitle(Odds ratio) eform
[Link]
Windows users click here to open the file [Link] in Word (you
dir : seeout
can replace this name with your own) . Otherwise follow the Mac
instructions.
Mac users click here to go to the directory where [Link] is saved, open it with Word
(you can replace this name with your own)
For more details/options and examples type
help outreg2
OTR Source: [Link]
PU/DSS/OTR
Regression: publishing regression output (outreg2)
For predicted probabilities and marginal effects, see the following document
[Link]
OTR Source: [Link]
PU/DSS/OTR
Using outreg2 for summary statistics: all variables in dataset
sysuse auto, clear
outreg2 using [Link], replace sum(log)
. outreg2 using [Link], replace sum(log)
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291 15906
mpg 74 21.2973 5.785503 12 41
rep78 69 3.405797 .9899323 1 5
headroom 74 2.993243 .8459948 1.5 5
trunk 74 13.75676 4.277404 5 23
weight 74 3019.459 777.1936 1760 4840
length 74 187.9324 22.26634 142 233
turn 74 39.64865 4.399354 31 51
displacement 74 197.2973 91.83722 79 425
gear_ratio 74 3.014865 .4562871 2.19 3.89
foreign 74 .2972973 .4601885 0 1
Following variable is string, not included:
make
Windows users click here to open the file [Link] in Word (you
[Link]
dir : seeout
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
OTR For more details/options and examples type help outreg2
Using outreg2 for summary statistics: selected variables
sysuse auto, clear
outreg2 using [Link], replace sum(log) keep(price mpg turn)
. outreg2 using [Link], replace sum(log) keep(price mpg turn)
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291 15906
mpg 74 21.2973 5.785503 12 41
rep78 69 3.405797 .9899323 1 5
headroom 74 2.993243 .8459948 1.5 5
trunk 74 13.75676 4.277404 5 23
weight 74 3019.459 777.1936 1760 4840
length 74 187.9324 22.26634 142 233
turn 74 39.64865 4.399354 31 51
displacement 74 197.2973 91.83722 79 425
gear_ratio 74 3.014865 .4562871 2.19 3.89
foreign 74 .2972973 .4601885 0 1
Following variable is string, not included:
make
Windows users click here to open the file [Link] in Word (you
[Link]
dir : seeout can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
OTR For more details/options and examples type help outreg2
Using outreg2 for summary statistics:
selected variables in dataset and selected statistics
sysuse auto, clear
outreg2 using [Link], replace sum(log) keep(price mpg turn) eqkeep(N mean)
. outreg2 using [Link], replace sum(log) keep(price mpg turn) eqkeep(N mean)
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291 15906
mpg 74 21.2973 5.785503 12 41
rep78 69 3.405797 .9899323 1 5
headroom 74 2.993243 .8459948 1.5 5
trunk 74 13.75676 4.277404 5 23
weight 74 3019.459 777.1936 1760 4840
length 74 187.9324 22.26634 142 233
turn 74 39.64865 4.399354 31 51
displacement 74 197.2973 91.83722 79 425
gear_ratio 74 3.014865 .4562871 2.19 3.89
foreign 74 .2972973 .4601885 0 1
Following variable is string, not included:
make
Windows users click here to open the file [Link] in Word (you
[Link]
dir : seeout
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
OTR For more details/options and examples type help outreg2
Using outreg2 for summary statistics:
selected variables in dataset and detail statistics
*NOTE: The option “sum(detail)” will give all the summary
statistics shown below for the selected variables but it will
show in the output window results for all the variables in the
dataset. This is similar to typing “summarize, detail”
sysuse auto, clear
set more off
outreg2 using [Link], replace sum(detail) keep(price mpg turn)
Windows users click here to open the file [Link] in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
OTR For more details/options and examples type help outreg2
Using outreg2 for summary statistics:
selected variables in dataset and selected detail statistics
*NOTE: The option “sum(detail)” will give all the summary statistics shown below for
the selected variables but it will show in the output window results for all the
variables in the dataset. This is similar to typing “summarize, detail”
* The option “p50” gives the median
sysuse auto, clear
set more off
outreg2 using [Link], replace sum(detail) keep(price mpg turn) eqkeep(N mean p50)
Windows users click here to open the file [Link] in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
OTR For more details/options and examples type help outreg2
Using outreg2 for summary statistics:
by group, selected variables in dataset and detail statistics
*NOTE: You need to specify either keeping statistics (eqkeep) and droping variables
(drop) or viceversa. You can’t specify eqkeep() and keep() at the same time
sysuse auto, clear
set more off
bysort foreign: outreg2 using [Link], replace sum(log) eqkeep(N mean) drop(make rep78
headroom trunk weight length displacement gear_ratio)
Windows users click here to open the file [Link] in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
OTR For more details/options and examples type help outreg2
Using outreg2 for frequencies
sysuse auto, clear
outreg2 foreign using [Link], replace cross
Windows users click here to open the file [Link] in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
For more details on what are frequencies and how to interpret the
table see: [Link]
OTR For more details/options and examples type help outreg2
Using outreg2 for crosstabs
*Taken from outreg2’s help file. It can report only column
percents.
sysuse auto, clear
egen mileage=cut(mpg), group(10)
outreg2 mileage foreign using [Link], replace cross
Windows users click here to open the file [Link] in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where [Link] is saved, open it
with Word (you can replace this name with your own)
NOTE: If you add the option side (after cross) it will put all values in columns.
For more details on what are crosstabs and how to interpret the table
see: [Link]
OTR For more details/options and examples type help outreg2