Attaullah Shah
Post count: 70

You need to add the variable name in the loop, try this:

loc NextRow 2
flexmat reset
flexmat  addrow, data (Variable, Obs, Mean, Std.Dev., Max, Min) row(1)

foreach var in twear tnonwear move comm mon oth {

    sum nrobot_`var'

    flexmat  addrow, data (`var', `r(N)',`r(mean)', `r(sd)',`r(max)', `r(min)') row(`NextRow') dec(3)
    loc ++NextRow
asdocx export