asdocx: Export from Stata to Word, Excel, LaTeX & HTML Forums asdocx Forum flexmat summary statistics in a loop | asdocx | Stata

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Thanh Binh Le
    Participant
    Post count: 1

    Dear Professor Attaullah,
    I am working on a loop and trying to print the summary statistics to Words document, but the table does not include the variable names.
    Also, can you please instruct me on how to include “bys year” command into the loop using asdocx?
    Thank you so much
    My command is:

    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 (`r(N)',`r(mean)', `r(sd)',`r(max)', `r(min)') row(`NextRow') dec(3)
        loc ++NextRow
    
    }
    asdocx export
    Attaullah Shah
    Moderator
    Post count: 76

    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
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.