I am running an ordered probit with four levels (A lot, Somewhat, Little, Not at all) on a female variable and some controls:

* Baseline only
eststo, title ("OProbit1"): /*quietly*/ oprobit retincome_worry i.female  $control_socio, vce(robust)
estimate store OProbit1

* Baseline + Health Controls

eststo, title ("OProbit3"): oprobit retincome_worry i.female  $control_socio $control_health, vce(robust)
estimate store OProbit3

I am doing this for marginal effects of the female variable:

* TABLE BASELINE

estimate restore OProbit1
margins, dydx(i.female) predict (outcome(1)) atmeans post
outreg using results\Reg_margins\Reg2.tex, noautosumm replace rtitle(A lot) ctitle(Social Controls)  title(Worry about Retirement Income)

estimate restore OProbit1
margins, dydx(i.female) predict (outcome(2)) atmeans post
outreg using results\Reg_margins\Reg2.tex, noautosumm append rtitle(Somewhat)  

estimate restore OProbit1
margins, dydx(i.female) predict (outcome(3)) atmeans post
outreg using results\Reg_margins\Reg2.tex, noautosumm append rtitle(Little)  

estimate restore OProbit1
margins, dydx(i.female) predict (outcome(4)) atmeans post
outreg using results\Reg_margins\Reg2.tex, noautosumm append rtitle(Not at all) tex 

* TABLE BASELINE + HEALTH

estimate restore OProbit3
margins, dydx(i.female) predict (outcome(1)) atmeans post 
outreg using results\Reg_margins\Reg3.tex, noautosumm replace rtitle(A lot) ctitle(Baseline and Health) title(Worry about Retirement Income)

estimate restore OProbit3
margins, dydx(i.female) predict (outcome(2)) atmeans post
outreg using results\Reg_margins\Reg3.tex, append noautosumm rtitle(Somewhat)  

estimate restore OProbit3
margins, dydx(i.female) predict (outcome(3)) atmeans post
outreg using results\Reg_margins\Reg3.tex, append noautosumm rtitle(Little) 

estimate restore OProbit3
margins, dydx(i.female) predict (outcome(4)) atmeans post
outreg using results\Reg_margins\Reg3.tex, append noautosumm rtitle(Not at all) tex

I currently have four tables (see examples for two of them), each with a column name which is the controls included in the model and four rows with each level:

Table with Baseline Controls

Table with Baseline and Health Controls

How can I have all of this in a single table, keeping the four rows and adding more columns?

1 Answers

1
Pearly Spencer On Best Solutions

You can get the desired output using the community-contributed command esttab.

First, define the program appendmodels (obtained from here):

capt prog drop appendmodels
*! version 1.0.0  14aug2007  Ben Jann
program appendmodels, eclass
    // using first equation of model
    version 8
    syntax namelist
    tempname b V tmp
    foreach name of local namelist {
        qui est restore `name'
        mat `tmp' = e(b)
        local eq1: coleq `tmp'
        gettoken eq1 : eq1
        mat `tmp' = `tmp'[1,"`eq1':"]
        local cons = colnumb(`tmp',"_cons")
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1,1..`cons'-1]
        }
        mat `b' = nullmat(`b') , `tmp'
        mat `tmp' = e(V)
        mat `tmp' = `tmp'["`eq1':","`eq1':"]
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
        }
        capt confirm matrix `V'
        if _rc {
            mat `V' = `tmp'
        }
        else {
            mat `V' = ///
            ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
            ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
        }
    }
    local names: colfullnames `b'
    mat coln `V' = `names'
    mat rown `V' = `names'
    eret post `b' `V'
    eret local cmd "whatever"
end

Next, run the following (here I use Stata's fullauto toy dataset for illustration):

webuse fullauto, clear
estimates clear

forvalues i = 1 / 4 {
    oprobit rep77 i.foreign
    margins, dydx(foreign) predict (outcome(`i')) atmeans post
    estimate store OProbit1`i'
}

appendmodels OProbit11 OProbit12 OProbit13 OProbit14 
estimates store result1

forvalues i = 1 / 4 {
    oprobit rep77 i.foreign length mpg
    margins, dydx(foreign) predict (outcome(`i')) atmeans post
    estimate store OProbit2`i'
}

appendmodels OProbit21 OProbit22 OProbit23 OProbit24 
estimates store result2

forvalues i = 1 / 4 {
    oprobit rep77 i.foreign trunk weight
    margins, dydx(foreign) predict (outcome(`i')) atmeans post
    estimate store OProbit3`i'
}

appendmodels OProbit31 OProbit32 OProbit23 OProbit34 
estimates store result3

forvalues i = 1 / 4 {
    oprobit rep77 i.foreign price displ
    margins, dydx(foreign) predict (outcome(`i')) atmeans post
    estimate store OProbit4`i'
}

appendmodels OProbit41 OProbit42 OProbit43 OProbit44 
estimates store result4

Finally, see the results:

esttab result1 result2 result3 result4, keep(1.foreign) varlab(1.foreign " ") ///
labcol2("A lot" "Somewhat" "A little" "Not at all") gaps noobs nomtitles

-------------------------------------------------------------------------------------
                   (1)             (2)             (3)             (4)   
-------------------------------------------------------------------------------------
A lot          -0.0572         -0.0677         -0.0728         -0.0690   
               (-1.83)         (-1.67)         (-1.81)         (-1.67)   
Somewhat        -0.144**        -0.247***       -0.188**        -0.175*  
               (-2.73)         (-3.54)         (-2.86)         (-2.47)   
A little        -0.124          -0.290**        -0.290**        -0.163   
               (-1.86)         (-3.07)         (-3.07)         (-1.74)   
Not at all       0.198**         0.351***        0.252**         0.237*  
                (2.64)          (3.82)          (2.95)          (2.55)   
-------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

You can install esttab by typing the following in Stata's command prompt:

ssc install estout