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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: loop with egen


From   Richard Goldstein <richgold@ix.netcom.com>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index