Announcement

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

  • Esttab report different summary statistics under one column?

    Hi all,

    Many thanks in advance for any help you can offer. I'm currently using estpost , eststo, and esttab from SSC in Stata 15.1 and am running into issues combining multiple stored summary statistics into one column in a table with esttab.

    For confidentiality reasons I can't include my data but I'll use the auto dataset from Stata to demonstrate the issue.

    What I'd like to generate is a table with two columns: foreign==0 and foreign==1 that displays the mean value of mpg at each foreign level but also the proportions of rep78 values for each foreign level.

    I've tried the following code:

    Code:
    sysuse auto
    
    estpost su mpg if foreign==0
    eststo m1
    
    estpost su mpg if foreign==1
    eststo m2
    
    estpost tab rep78 if foreign==0
    eststo m3
    
    estpost tab rep78 if foreign==1
    eststo m4
    
    esttab m1 m2 m3 m4, cells(mean pct) nonumber nomtitle
    Which (understandably) generates a table with 4 columns, two being the mean values of mpg as generated with su and two being the proportions of rep78 as generated from tab.

    Is there a way to shift over the results from tab so that they're in the same columns as those from summarize? Essentially, to override what I think is the default to group the columns by the e() that they're storing?

    Thank you so much for any help you can offer and apologies if I'm missing any relevant information to make my question easier to understand!




  • #2
    You have to merge the models somehow, and it gets very confusing as you are also mixing means of a continuous variable and percentages of a categorical variable.

    Code:
    sysuse auto, clear
    
    estpost su mpg if foreign==0
    mat mean1= e(mean)
    
    estpost su mpg if foreign==1
    mat mean2= e(mean)
    
    estpost tab rep78 if foreign==0
    mat pct1= e(pct)
    
    estpost tab rep78 if foreign==1
    mat pct2= e(pct)
    
    mat out1= mean1, pct1
    estadd mat out1
    mat out2= mean2, pct2
    estadd mat out2
    
    esttab ., cells("out1 out2") nonumber nomtitle noobs drop(Total)
    Res.:

    Code:
    . esttab ., cells("out1 out2") nonumber nomtitle noobs drop(Total)
    
    --------------------------------------
                         out1         out2
    --------------------------------------
    mpg              19.82692     24.77273
    1                4.166667             
    2                16.66667             
    3                   56.25     14.28571
    4                   18.75     42.85714
    5                4.166667     42.85714
    --------------------------------------

    Comment

    Working...
    X