Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • desperately in need of helping with exporting sum stats table

    I am desperately looking for the solution on exporting the summary stats tables.
    I typed commands as below and this table is produced.

    estpost tabstat pwt_bc pwt_ac ct_bc ct_ac if emp_cd==0 | emp_cs==0 [aw=wt], by(dual) statistics(N mean sd p50 min max) col(stat)
    esttab est1 using mydoc1.rtf, replace cells("N mean sd p50 min max")

    Click image for larger version

Name:	stata1.png
Views:	1
Size:	24.9 KB
ID:	1612068


    This is what I have in the stata, but in the table exported in document, it shows like this:

    Click image for larger version

Name:	stata2.png
Views:	1
Size:	2.8 KB
ID:	1612069


    So I tried this command below instead,

    estpost tabstat pwt_bc pwt_ac ct_bc ct_ac if emp_cd==0 | emp_cs==0 [aw=wt], by(dual) statistics(N mean sd p50 min max) col(stat)
    esttab est1 using mydoc1.rtf, replace cells("pwt_bc pwt_ac ct_bc ct_ac ct_ch")



    and got this table like this:

    Click image for larger version

Name:	stata3.png
Views:	1
Size:	20.3 KB
ID:	1612070


    This table is what I want, but I want the X-axis and Y-axis switched. And I couldn't just get this. It took me several hours exploring online to find the commands but I failed.
    Can anyone help me out on this?



    My questions are:

    1) I want to have the sum stats and the variables switched. Why do I just not get them right? I want to have the variables in cells.

    2) Is there any other stata commands to produce sum stat tables with weight and export them easier? I tried asdoc but asdoc doesn't get me the weighted values. aweight didn't work.



  • #2
    Maybe like this:

    Code:
    global vars var1 var2 var3
    
    eststo D1: estpost summarize $vars if (emp_cd==0 | emp_cs==0) & dual == 0 [aw=wt], det
    eststo D2: estpost summarize $vars if (emp_cd==0 | emp_cs==0) & dual == 1 [aw=wt], det
    eststo D3: estpost summarize $vars if (emp_cd==0 | emp_cs==0) [aw=wt], det
    
    
    esttab D1 D2 D3 using "desc.rtf", cells("count mean sd p50 min max") rtf replace
    Best wishes

    (Stata 16.1 MP)

    Comment


    • #3
      I tried it and it worked! Thank you so much.
      But tables of D1 and D2 are listed in the same cells. Any additional command to have them listed in separate cells?

      Comment


      • #4
        I am not really sure what you mean. Could you elaborate and provide a screenshot or example?
        Best wishes

        (Stata 16.1 MP)

        Comment

        Working...
        X