Dear Statalists,

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
command at the same time and here is the code I use but doesn't work:

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)
}
}
The main issue is the excel cell part doesn't move simultaneously with variables but been replaced every time a new variable kicks in. Also these are made up variable names, the real ones are names of 26 diseases, therefore there is no number attached to each variable name.

Much appreciated if someone could help me on this.

Very best wishes