Professional Documents
Culture Documents
See also the course’s documents ‘Making Contingency Tables in Stata’ and ‘Editing
Stata estab and outreg2 Tables in MS-Word’.
Gary Klass, “Presenting Data: Tabular and graphic display of social indicators”
http://lilt.ilstu.edu/gmklass/pos138/datadisplay/
Note: Copying tables directly from the Stata Results-window to MS-Word works well
if MS-Word is formatted to display Courier 11 point or less (which is a fixed-space
font). If necessary you can then change to a proportionally spaced font (such as
Times New Roman) in MS-Word, but doing so may involve considerable formatting
(see the course web document ‘Editing estab and outreg2 Tables in MS-Word’).
Here are examples of Stata table-making commands, which you can obtain by using
‘findit,’ ‘help,’ Stata listserv, ‘UCLA Resources for Learning Stata’, and ‘ssc
whatsnew.’
§ tabstat, statsmat, tablemat, fsum, and tabform: summary tables (see also
‘findit …’ for svytabs and svytabform).
§ The combination of eststo and esttab (which is a spin-off from estout; see
below): not only displays publication-style regression tables in the Stata
results window, but also can directly produce them in Word or Excel, and
output them to LaTeX.
§ outreg2: can directly create regression tables in Word or Excel, and output
them to LaTeX.
1
By-group as column variable
Community1 Community 2 Community 3
Ave. income 12,236 15,151 16,204
% poverty 34.3% 31.1% 29.5%
§ tabstat
help tabstat
tabstat read write math science, stats(mean med sd min max) format(%9.2f)
tabstat read write math science, stats(mean med sd min max) format(%9.2f)
col(stats)
tabstat read write math science, stats(mean med sd min max) format(%9.2f)
by(female) col(stats)
§ statsmat (findit & download; basically the same as tabstat, but displays &
exports table as matrix)
findit statsmat
help statsmat
§ tablemat (findit & download; permits more flexible use of by-variables and
labeling than tabstat & statsmat; displays the same statistics as tabstat, but
displays only one statistic at a time)
findit tablemat
help tablemat
tablemat read write math, st(mean) by(female ses prog) name(table) format(%9.2f)
findit fsum
help fsum
fsum read write math, s(n miss mean sd lci uci) format(%9.2f)
2
§ tabform (findit & download; permits display of confidence intervals, which
tabstat & tablemat do not; tests & displays results of equality of means,
which tabstat, statsmat, tablemat, & fsum do not)
findit tabform
help tabform
tabform read write math using table.xls, by(ses) sd ci dec(2) sdbracket cibrace
nototal
Open Excel, navigate to table.xls, and follow the wizard instructions to display the
table.
tabform displays only the mean if other stat istics are not requested.
tabform read write math using table.xls, by(ses) sd ci bdec(2) sdbracket cibrace
nototal vertical
findit tabout
help tabout
tabout ses schtyp using sesst, cell(col) format(1) clab(Col_%) stats(chi2) replace
Select MS-Word file ‘sesst’ (located in current folder), and edit in Word or copy/paste
to Excel.
Some options:
cell: freq, cell, row, col, cum [all can be specified)
format: # decimal points; specify in order of types of cell entries specified
clab: table’s title
layout: how the columns are laid out stats: types of statistics specified
findit mkcorr
help mkcorr
3
mkcorr read write math science socst, log(hsb2corr) sig means cdec(2) mdec(2)
casewise
Note: The default is pairwise (pwcorr). You must specify ‘casewise’ if you want the
equivalent results of ‘corr’.
Select file ‘hsb2corr’ (located in current folder) in Word, and edit in Word or
copy/paste to Excel.
Options:
sig: display significance test p-values
cdec( ): # decimal points displayed in correlation coefficients
means: display descriptive numerical summary
mdec( ): # decimal points displayed in descriptive numerical summary
casewise: display casewise results (instead of default pairwise results)
findit corrtab
help corrtab
corrtab read write math science, obs sig bonf vsort(read) format(%9.2f)
corrtab read write math science, cwd obs sig bonf vsort(read) format(%9.2f)
corrtab read write math science, spearman obs sig bonf vsort(read) format(%9.2f)
Note: pairwise (the equivalent of pwcorr in Stata) is the default unless cwd
(casewise, equivalent to ‘corr’ in Stata) is not specified. Spearman may also be
specified. corrtab is designed for a maximum of eight variables.
findit makematrix
help makematrix
findit esttab
help esttab help eststo
4
reg science math read female schtyp
eststo
esttab, se starlevels(+ .10 * .05 ** .01) b(%9.2f) r2(%9.2f) ar2(%9.2f) aic bic
nodepvars nomtitles title(“OLS Science Models”) addnotes(“Note: Put your notes
here.”)
Note: ‘csv’ instead of ‘rtf’ creates an Excel document. See ‘help esttab’ regarding
‘drop,’ ‘keep,’ ‘order’; formatting numbers; ‘compress’ (which squeezes the column
space); ‘wide’ (to display standard errors next to coefficients); ‘ci’ (to display
confidence intervals); ‘beta’ (to display standardized coefficients); optional
specification of ‘replace’ or ‘append’; and other options.
esttab, eform se b(%9.3f) starlevels(+ .10 * .05 ** .01) scalars(ll df_m aic bic)
sfmt(%9.3f %9.0f %9.3f) nodepvars title(“Logistic Whites vs. Others Model”)
addnotes(“Note: Put your notes here.”)
Or:
estab using whites.rtf, eform se b(%9.3f) starlevels(+ .10 * .05 ** .01) scalars(ll
df_m aic bic) sfmt(%9.3f %9.0f %9.3f) nodepvars title(“Logistic Whites vs. Others
Model”) addnotes(“Note: Put your notes here.”)
tab prog
tab prog, nolabel
mlogit prog math read science female, base(2) rrr nolog
eststo
esttab m1, eform se unstack b(%9.3f) starlevels(+ .10 * .05 ** .01) scalar(ll chi2
df_m aic bic) scalars(ll df_m aic bic) sfmt(%9.3f %9.0f %9.3f) nodepvars nomtitles
title(“Multinomial Logit Model”) addnotes(“Note: Put your notes here.”)
5
Or:
estab using whites.rtf, eform se unstack b(%9.3f) starlevels(+ .10 * .05 ** .01)
scalar(ll chi2 df_m aic bic) scalars(ll df_m aic bic) sfmt(%9.3f %9.0f %9.3f)
nodepvars nomtitles title(“Multinomial Logit Model”) addnotes(“Note: Put your notes
here.”)
You can routinely make easy-to-read, full-feature regression tables for exploratory
analysis if you include the following commands in profile.do (specifying any function
keys you wish):
* eststo
global F1 = “eststo ”
Here’s how to use the first of these commands to make an OLS regression working
table, given that you’ve inserted the above commands into profile.do:
F2 [or whatever function key you may have programmed, to produce the table]
6
Here’s the result:
-----------------------------------------------
(1) (2)
-----------------------------------------------
read 0.435*** 0.261***
(0.0633) (0.0680)
math 0.282***
(0.0755)
female -3.570***
(1.059)
Click on ‘seeout’ to see Stata display & ‘ols.RTF’ to see Word display.
Table>Format>Hide gridlines
7
Some options (after ‘,’):
word: output text to a Word file, which is saved in the current directory
excel: output text to an Excel file
onecol: suppresses multi-column format if relevant
long: accompanies onecol, forcing Word of Excel to adopt one-column format
replace: replaces previous model or format
append: appends additional models (instead of ‘replace’)
e(): specify added stats, e.g., e(ll df_m chi2 aic); or e(all); does not display
publication-style stat names (see ‘addstat’). After estimating a model, type ‘ereturn
list’ to obtain options and codes.
addstat(): to add other stats along with stat names. E.g., addstat(Log likelihood,
e(ll), DF, e(df_m), chi2, e(chi2), AIC, e(aic)). After estimating a model, type
‘ereturn list’ to obtain options and codes.
Note: title and note options give the same output whether or not the text is enclosed
within quotation marks. outreg2 gives an error message if addnote is formatted as
follows: addnote(Source: my data). So don’t include a colon in the text.
E.g.:
reg science math read
outreg2 using m1, bdec(2) bfmt(f) alpha(0.01, 0.05, 0.10) adjr2 addstat(AIC, e(aic))
title(OLS) addnote(Study data) word replace
Click on ‘seeout’ to see STATA display & ‘m1.RTF’ to see Word display.
Table>Format>Hide gridlines
Note: To display more than three levels of significance - alpha(0.001 0.01, 0.05,
0.10) symbol(***, **, *, +) . To display two or more models in the same table –
outreg2 using m1, …… append
8
§ Publication-style logistic regression table (outreg2)
See the course document ‘Editing Stata’s esttab or outreg2 regression tables in MS-
Word’.
Note: eform specifies odds-ratios. See other outreg2 options above. To display more
than three levels of significance - alpha(.001 .01, .05, .10) symbol(***, **, *, +) .
To display two or more models in the same table – outreg using m1, …… append