
See also the following resources related to asdoc. If we were to append the results to the same file, we shall add append after the comma or leave it (append is the default, we can use replace to replace the existing file) asdoc cor Īnd for creating a table of correlations among all numerical variables, we shall just type asdoc cor. Let us load the auto.dta set for practice and find summary stats of all numeric variables and send the output to MS Word with asdoc sysuse autoĪnd voila, a beautiful table of the descriptive statistic is ready. We shall add just asdoc as a prefix to sum. For example, we use the sum command to find summary statistics of all numeric variables in the dataset. You need to add just asdoc as a prefix to Stata commands. Another command, asdoc, is perhaps more appropriate for this purpose, and will be discussed in a future article.Using asdoc is pretty easy. Though outreg2achieves all of the above well, it may not be the best command to output summary statistics from Stata. outreg2 foreign rep78 using results, word replace cross In case of a categorical variable, it includes each category in the table. The option of crossallows us to output the frequency distribution of any variable we specify after outreg2. The results from the regressions will be reported separately for foreign cars (where variable ‘foreign’ = 1) and domestic cars (where variable ‘foreign’ = 0) Outputting Frequency Distribution bysort foreign: outreg2 using results, word replace sum(log) eqkeep(N mean sd) This variable assumes the value of 1 when a vehicle is foreign, and 0 when a vehicle is domestic. Here we, use ‘foreign’ as our categorical variable of choice. To obtain summary statistics for each category in a categorical variable, we simply add the bysort prefix. Regress price mpg headroom rep78 outreg2 using results, word replace sum Summary Statistics for Different Groups/Categories To obtain summary statistics for variables and observations used in a regression only we first run the regression, then use the outreg2command right after it with an option of sum We therefore find estimates from only 69 observations reported in the regression results. However, as from Stata 10.1, they now have a new missing option. egen (see D egen) functions total() and rowtotal() by default yield 0 for the total of missings. This is because Stata omits any observation where rep78 is missing. r(sumw) 0 r(sum) 0 The sum (and sum of weights) is not explicit in the output from summarize, but it is calculated on the side and put in r-class results. When we regress price on the other three variables, we note that the regression used 69 observations even though there were variables with 74 observations. Therefore, the number of observations used in regressions is often lower for each variable than the number of observations reported for them in the summary statistics.įor example, if we summarise the data, we see that the variables ‘price’, ‘mpg’, and ‘headroom’ have 74 observations. The following command will return an error since both eqkeep()and keep()appear simultaneously: outreg2 using results, word replace sum(log) eqkeep(N mean sd) keep(price mpg headroom trunk rep78) Summary Statistics for Observations Used In a Regressionīecause of Stata’s casewise/listwise deletion, it omits observations with missing values from any regression analysis done. To obtain a summary table with a few statistics for a few variables, you can use eqkeep() to retain statistics, and drop() to omit variables, or vice versa. However, we cannot specify both the eqkeep() and keep() options at the same time. If we only wish to report, say the number of observations, mean and standard deviation of our variables (and not the minimum and maximum that are also reported by default), we add the keep()option to specify which variables we want to retain: outreg2 using results, word replace sum(log) eqkeep(N mean sd) Some Statistics for Some VariablesĪs seen above, we use the keep()option to retain variables that we specify in the parenthesis.

We can report these extra statistics through the outreg2command by typing detailin the parenthesis of the sum()option used above: outreg2 using results, word replace sum(detail) Some Summary Statistics for All Variables With the summarize command, which is typically used to return summary statistics, Stata allows an option of detail.This option outputs a table with additional statistics. We can also replace variable names with variable labels, a step that we explain in one of our introductory outreg2articles. outreg2 using results, word replace sum(log) This option indicates to Stata that a summary table is being output. To report summary statistics for all the variables in our dataset, we use a familiar outreg2syntax with a new option of sum(log).

For this guide, we start by using Stata’s inbuilt 1978 Automobile dataset and describing it using: sysuse auto.dta All Summary Statistics for All Variables
