Dear Statalisters,

I am interested in the summary statistics (specifically, the number of observations and mean) of a loop including a number of levels. Currently I have:

Code:
sysuse auto.dta
levelsof make
foreach lev in `r(levels)' {
di "`lev'"
sum price if make == "`lev'"
}
I wish to export the number of observations as well as the mean of each "level" (e.g. in "make") to a Word file, where the first column includes the name of the "level", the number of observations is included in the second column, and the third column includes the mean values.

Can anyone help me on this? Thank you in advance.

Kind regards,

Eline