Announcement

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

  • Row names with esttab using over()

    Hi all,

    I'm using Stata 17 and the user-written esttab command from SSC to create/export tables to rtf. I need to use the mean command with the over suffix because I'm working with complex survey data. My issue is getting the correct format for the names of the rows. Here's an illustration using the auto data.

    Code:
    sysuse auto, clear
    eststo: mean weight, over(foreign)
    This prints a table in the display with the row names determined by the labels for foreign, i.e. "Domestic" and "Foreign". However, when I utilize the esttab command,
    Code:
    esttab, wide se nostar
    the row names are "[email protected]" and "[email protected]". The question is how do I get the row names as "Domestic" and "Foreign"?

    I recognize this can be done manually like so:

    Code:
    esttab, wide se nostar varlabels([email protected] "Domestic" [email protected] "Foreign")
    However, I'm dealing with a very large number of variables so need an automated solution. Thanks in advance.
    Last edited by Alex Taylor; 07 Jul 2021, 01:55.

  • #2
    esttab takes whatever is in e(b), and mean does not store the coefficients as you expect - so there is not much that you can do about that. I would suggest that you use regress in place of mean.

    Code:
    webuse nhanes2f
    svyset psuid [pweight=finalwgt], strata(stratid)
    svy: mean zinc, over(race)
    svy: regress zinc ibn.race, nocons
    esttab, wide se nostar label
    Res.:

    Code:
    . svy: mean zinc, over(race)
    (running mean on estimation sample)
    
    Survey: Mean estimation
    
    Number of strata =      31      Number of obs   =        9,189
    Number of PSUs   =      62      Population size =  104,176,071
                                    Design df       =           31
    
    --------------------------------------------------------------
                 |             Linearized
                 |       Mean   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
     c.zinc@race |
          White  |   87.49539   .4791963      86.51806    88.47272
          Black  |   85.08574   1.165209      82.70929     87.4622
          Other  |   83.57091   1.585463      80.33734    86.80448
    --------------------------------------------------------------
    
    .
    . svy: regress zinc ibn.race, nocons
    (running regress on estimation sample)
    
    Survey: Linear regression
    
    Number of strata   =        31                Number of obs     =        9,189
    Number of PSUs     =        62                Population size   =  104,176,071
                                                  Design df         =           31
                                                  F(   3,     29)   =     10616.73
                                                  Prob > F          =       0.0000
                                                  R-squared         =       0.9723
    
    ------------------------------------------------------------------------------
                 |             Linearized
            zinc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            race |
          White  |   87.49539   .4791963   182.59   0.000     86.51806    88.47272
          Black  |   85.08574   1.165209    73.02   0.000     82.70929     87.4622
          Other  |   83.57091   1.585463    52.71   0.000     80.33734    86.80448
    ------------------------------------------------------------------------------
    
    .
    . esttab, wide se nostar label
    
    ----------------------------------------------
                                  (1)            
                         serum zinc~)            
    ----------------------------------------------
    White                       87.50      (0.479)
    Black                       85.09      (1.165)
    Other                       83.57      (1.585)
    ----------------------------------------------
    Observations                 9189            
    ----------------------------------------------
    Standard errors in parentheses
    
    .

    Comment


    • #3
      Thanks, Andrew. Great idea. That should work!

      Comment

      Working...
      X