Sep 10, 2016

Latex tables using -esttab-

// Table 1
eststo clear
bysort male country: eststo: estpost summarize hwhrs phwhrs gap ///
                                               workhours pworkhours ///
                                               genderroles femaleemployment ///
                                               married higherincome phigherincome ///
                                               age preschool schoolage ///
                                               retired pretired, listwise

esttab using test.tex, main(mean) aux(sd) label nodepvar nostar nonote nonumbers ///
                       b(%9.2f) varwidth(35) compress booktabs ///
                       title("Descriptive statistics: Means and standard deviations by gender and country") ///
                       mgroups("Women" "Men", pattern(1 0 0 1 0 0) ///
                       prefix(\multicolumn{@span}{c}{) suffix(})   ///
                       span erepeat(\cmidrule(lr){@span})) replace 
 
// Table 2
eststo clear
levelsof country, local(country)
foreach i of local country {
  capture drop touse
  mark touse
  markout touse   hwhrs workhours pworkhours phwhrs ///
                  genderroles femaleemployment ///
                  i.relativeincome pretired retired ///
                  age preschool schoolage married

  eststo: regress hwhrs workhours pworkhours phwhrs ///
          if female == 1 & country == `i' & touse
  eststo: regress hwhrs workhours pworkhours phwhrs ///
                  genderroles femaleemployment ///
                  i.relativeincome pretired retired ///
                  age preschool schoolage married ///
                  if female == 1 & country == `i' & touse
}

esttab using test.tex, se ar2 label varwidth(35) b(%9.2f) compress nodepvars order(_cons) booktabs ///
        mtitles("Germany" "Germany" "USA" "USA" "Finland" "Finland") ///
        title("Determinants of weekly housework hours of women in West Germany, USA, and Finland. OLS coefficients") ///
        append