Aligning variables when outcome differs in etable in Stata

The etable command can be used to generate regression tables which can easily be exported. It's basically a replacement for the old user-written commands like outreg2.


. sysuse auto, clear
(1978 automobile data)
. quietly reg mpg headroom turn
. est store mod1
. quietly reg mpg headroom turn i.foreign
. est store mod2
. etable, estimates(mod1 mod2)

--------------------------------------
                         mpg     mpg
--------------------------------------
Headroom (in.)          -0.905  -0.928
                       (0.613) (0.614)
Turn circle (ft.)       -0.872  -0.958
                       (0.118) (0.145)
Car origin
  Foreign                       -1.337
                               (1.317)
Intercept               58.576  62.469
                       (4.263) (5.732)
Number of observations      74      74
--------------------------------------

However, if the outcome differs between models, it won't look quite as nice:


. quietly regress mpg headroom turn
. estimates store mod3
. quietly regress trunk headroom turn
. estimates store mod4
. etable, estimates(mod3 mod4)

--------------------------------------
                         mpg    trunk
--------------------------------------
Headroom (in.)          -0.905
                       (0.613)
Turn circle (ft.)       -0.872
                       (0.118)
Intercept               58.576
                       (4.263)
Headroom (in.)                   2.509
                               (0.438)
Turn circle (ft.)                0.380
                               (0.084)
Intercept                       -8.804
                               (3.044)
Number of observations      74      74
--------------------------------------

To fix this, use the `eqrecode` option to "recode" the outcomes to align them:


. etable, replay eqrecode(mpg = y trunk = y)

--------------------------------------
                         mpg    trunk
--------------------------------------
Headroom (in.)          -0.905   2.509
                       (0.613) (0.438)
Turn circle (ft.)       -0.872   0.380
                       (0.118) (0.084)
Intercept               58.576  -8.804
                       (4.263) (3.044)
Number of observations      74      74
--------------------------------------

The actual name ("y" in my code) doesn't matter as long as it is the same for both. Note that the outcomes are being recoded, not the stored estimates.

The source is this Statalist post.

Home | Back to blog

This work is licensed under CC BY-NC 4.0 Creative Commons BY-NC image