Hello!!

I am trying to export summary statistics like n mean sd median iqr min max for a series of variables, but can't seem to be able to.I keep getting errors:

foreach var of global n_mycomean {
tabstat `var', s(n mean sd median iqr)
estpost tabstat `var', s(n median iqr)
tabout `var' using mom4.xls, oneway replace
}

I've also tried to replace the tabout with esttab and estout, but the code still won't work.
Any tips? Below is the format I would like to have in excel
Variable n mean sd median iqr
Var 1
Var 2
Var 3
Var 20