// Open Allbus cumulation
use hs01 iscd975 age sex ///
using "ZA4586_v1-0-0.dta", clear
// Self-rated health
recode hs01 (4 5 = 1 "Poor health") ///
(3 2 1 = 0 "Good health") ///
(-1 -11 -9 = .) ///
, gen(poorhealth)
label var poorhealth "Poor self-rated health"
// Education
recode iscd975 (5 = 5 "Tertiary") ///
(4 = 4 "Post-secondary") ///
(3 = 3 "Upper secondary") ///
(2 = 2 "Lower secondary") ///
(1 = 1 "Basic") (-32 = .) ///
, gen(isced)
label var isced "Education"
// Age
recode age (-32 = .)
generate age10 = age/10
label var age10 "Age / 10"
// Sex
recode sex (1 = 0 "Male") ///
(2 = 1 "Female") ///
, gen(female)
label var female "Female sex"
// Indent value labels
labvalch3 female isced, prefix("\dumm ")
// Add this to Latex code
// % Indent for tables
// \newcommand*{\dumm}{\hspace*{0.5cm}}%
eststo clear
eststo: regress poorhealth ib3.isced age10 i.female, robust
esttab using table.tex, b(2) se(2) booktabs replace ///
label nobaselevels nonumber ///
modelwidth(25) varwidth(33) ///
stats(N, fmt(%8.0gc)) ///
refcat(1.isced "Education (ref. Upper secondary)" ///
1.female "Sex (ref. Male)", nol) ///
title("Poor self-rated health regressed on education, age, and sex, linear probability model")
// Alternative approach (that also works for .rtf tables)
labvalch3 female isced, subst("\dumm " "")
*ssc install elabel
elabel define female isced (= #) (= " " + @) , modify
// Note that the leading sapce don't seem to show up in a frequency table with -fre-
esttab using table.rtf, b(2) se(2) replace ///
label nobaselevels nonumber ///
modelwidth(25) varwidth(33) ///
stats(N, fmt(%8.0gc)) ///
refcat(1.isced "Education (ref. Upper secondary)" ///
1.female "Sex (ref. Male)", nol) ///
title("Poor self-rated health regressed on education, age, and sex, linear probability model")