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/