1
votes

I would like to make a summary statistics table using esttab from the estout package on SSC. I can make the table just fine, but I would like to add a column that counts the number of non-missing observations for each variable. That is, some variables may not be complete and I would like this to be clear to the reader.

In the example below I removed the first five observations for price, so I would like a 69 in that row. But my code doesn't include row-specific observation counts, only the total number of observations in the footer.

sysuse auto, clear
estpost summarize, detail
replace price = . in 1/5
local screen ///
    cells("N mean sd min p50 max") ///
    nonumber label 
esttab, `screen'

This yields an empty N column, which I would prefer to have at 69 , followed by all 74s.

1

1 Answers

5
votes

Is this it:

clear all
set more off

*----- exmple data -----

sysuse auto, clear
keep price mpg rep78 headroom

replace price = . in 1/5

*----- what you want -----

estpost summarize, detail

local screen cells("count mean sd") nonumber label noobs

esttab, `screen'

?

It just uses count. esttab is a wrapper for estout, and the help for the latter documents that it will take "results from e(myel)", which you have from estpost summarize, detail.

An alternative is:

tabstat _all, statistics(count mean sd) columns(statistics)

Yet another one, only that it allows variable labels to be displayed:

fsum _all, stat(n mean sd) uselabel

fsum is from SSC.