Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: means of dependent variables in estout

From   Matthew Pearson <>
Subject   st: means of dependent variables in estout
Date   Tue, 31 Oct 2006 12:34:57 -0800

Hi all,

This is my first post, so please bear with my if I have made some mistakes. I spent some time with a colleague yesterday trying to figure out how to get estout to report the means and standard deviations of the dependent variables in the stats option, with r- squared and N, etc. This proved to be quite a bit different from reporting the means of the regressors, which is detailed in the instructions. I thought I would post how I did it in case anyone else found it useful. If there is a better way that anyone knows of, then perhaps you can correct me, but this worked for me, and I could not find a simpler way to do it.

*First, we create a subroutine (which I called "mu" and "sig" respectively) to get the means and SDs from r( ) to e( ):

program estadd_mu, eclass
syntax [ , prefix(name) * ]
local depvar=e(depvar)
sum `depvar'
local mu=r(mean)
ereturn scalar `prefix'mu = `mu'

program estadd_sig, eclass
syntax [ , prefix(name) * ]
local depvar=e(depvar)
sum `depvar'
local sig=r(sd)
ereturn scalar `prefix'sig = `sig'

*Next, we use estadd, after the regression(s), and before estout, to add the stats we generated to the stored estimates:

estadd [depvarlist], stats(mu sig)

*And finally, in the estout command, add mu and sig to the stats( ) option, along with other stats you may want.

That's all. I hope this is helpful.


Matthew Pearson
Graduate Student
Department of Economics
University of California, Davis

* For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index