I need to obtain an average of averages from a series of variables. This is similar to a mean of a sampling distribution. So I use a foreach loop to summarise each variable in varlist. I then use a the scalar command to store each mean of each variable in varlist. Then I want to summarize the stored means to generate a mean. Here is what I am trying;
I do not think I am successful here for each time the loop runs, the scalar is replaced. Is there a way to automatically rename the scalars? Could there be a better way than what I am currently doing?
Code:
forear x in varlist var1 var2 var3 var4 var5{ display "***********************************" display "`x'" display "***********************************" sum `x' scalar mean = r(mean) list mean di (mean1 mean2 mean3 mean4 mean5)/5 }
Comment