Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: loop with egen


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: loop with egen
Date   Fri, 08 Feb 2013 08:35:35 -0500

you need to supply a varlist as in

foreach v of var mpg turn weight {

Rich

On 2/8/13 8:29 AM, Nahla Betelmal wrote:
> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index