I'm wondering if anyone could help me on this. I have a dataset containing 26 variables (say var1 - var26), I would like to get the no. of obs and mean of each variable and export them into a pre-created excel sheet. For example, for var1, I want to export the no. of obs and mean in cell A3 and B3, for var2 in cell A4 and B4, and accordingly until the last variable var26 in cell A28 and B28. It seems in need to use two
Code:
foreach
Code:
foreach x of varlist var1 - var26 { sum `x' foreach i of numlist 3/28 { putexcel A`i' = r(N) putexcel B`I' = r(mean) } }
Much appreciated if someone could help me on this.
Very best wishes
0 Response to Help need please for a foreach command
Post a Comment