help outsum

Write formatted descriptive statistics to a text file

outsum varlist [if] [in] [weight] using filename [, append nolabel noparen bracket nonobs nonotes replace comma quote title(textlist) ctitle(textlist) addnote(textlist)]

aweights, fweights and iweights are allowed; see weight.


outsum writes means and standard deviations to an external text file, in much the same way outreg produces formatted regression output, i.e. it creates an ASCII text file with columns separated with tab characters and standard deviations displayed in parentheses below the means. The major difference is that the user must specify a varlist (using wildcards or hyphenated syntax) directly. As in outreg, the using clause specifies the name of the new or existing ASCII file that will contain the means and standard deviations.

The options are largely the same as for outreg.


append specifies that new descriptive statistic output be appended to an existing output file. In general, the same outsum options should be used in the original output and each appended column. The notes at the bottom of the table explaining the standard deviations are correct for the first column of descriptive statistics in the output file. If subsequently appended results change the use of parentheses or brackets, the notes will not be appropriate for all the columns. This problem can be addressed with a combination of nonotes and addnote.

nolabel specifies that variable names rather than variable labels be used to identify coefficients.

noparen specifies that no parentheses be placed around standard deviations.

bracket specifies that square brackets [] be used rather than parentheses () around standard deviations.

nonobs specifies that the number of observations in the dataset not be reported.

nonotes specifies that notes explaining the standard deviations not be included.

replace specifies that it is okay to replace filename if it already exists.

comma specifies that the ASCII file output be separated by commas rather than by tabs. This can cause problems if any of the user-defined text has commas in it (such as variable labels, title, ctitle, addstat, or addnote). If that is the case, consider using quote as well.

quote specifies that string variables be enclosed in double quotes.

title(textlist) specifies a title or titles at the top of the regression table. The maximum title length is 80 characters. Additional characters will be cut off. When descriptive statistics are appended together, the table title must be specified in the first outsum call; titles specified in subsequent outsum ... append calls will be ignored. Note that when converting the outsum text output to a table in a word processor or a spreadsheet, it is easier to leave out the title row out of the text selected for conversion.

ctitle(textlist) specifies the title above the column of means and standard deviations. By default if no column title is specified, the label or name of the variable is displayed.

addnote(textlist) specifies user-added notes to be displayed in new lines at the bottom of the outsum table. When descriptive statistics are appended together, addnote must be specified in the first outsum call; addnotes specified in subsequent outsum ... append calls will be ignored. addnote is consistent with nonotes. A blank line can be inserted by including "" as a note.


. use http://stata-press.com/data/r9/auto, clear

(1978 Automobile Data)

. outsum mpg foreign weight using auto1, ctitle("Full sample")

. type auto1.out

Variable Full sample Mileage (mpg) 21.2973 (5.7855) Car type .2973 (.4602) Weight (lbs.) 3019.459 (777.1936) Observations 74 Standard deviations in parentheses

. outsum mpg weight using auto1 if foreign==0, append ctitle("Domestic")

. type auto1.out

Variable Full sample Domestic Mileage (mpg) 21.2973 19.8269 (5.7855) (4.7433) Car type .2973 (.4602) Weight (lbs.) 3019.459 3317.115 (777.1936) (695.3637) Observations 74 52 Standard deviations in parentheses


Kerry L. Papps, Cornell University, USA


Also see