Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: loop with egen


From   Nahla Betelmal <nahlaib@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: loop with egen
Date   Fri, 8 Feb 2013 13:29:52 +0000

Dear Statalist,

I am trying to generate the mean and standard deviation for more than
30 variables. I tried to do that using the following loop

foreach v of var {
egen mean = mean(`v')
egen sd = sd(`v')
}

however, it only generate the mean and standard deviation for the
first variable only.

I got this message :mean already defined
r(110);

what should I add to the loop , so it can generate the mean and
standard deviation for each variable in separate column?

Many thanks

Nahla
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index