// 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")
Showing posts with label Value labels. Show all posts
Showing posts with label Value labels. Show all posts
Oct 11, 2019
Indent value labels of categorical variables for -esttab-
Jun 20, 2015
Random graphs (49): Means with confidence intervals
tempname foo
tempname cogscore
postfile `foo' time ART cog coglb cogub using `cogscore', replace
levelsof(time), local(timepoint)
levelsof(ART), local(art)
foreach y of local art {
foreach x of local timepoint {
qui reg COG if time == `x' & ART == `y'
local cog = _b[_cons]
local coglb = _b[_cons] - (1.96 * _se[_cons])
local cogub = _b[_cons] + (1.96 * _se[_cons])
di `timepoint' _skip(5) `art' _skip(5) `cog' _skip(5) `coglb' _skip(5) `cogub'
post `foo' (`x') (`y') (`cog') (`coglb') (`cogub')
}
}
postclose `foo'
use `cogscore', clear
label define time 1 "Age 3" 2 "Age 5" 3 "Age 7" 4 "Age 11"
label val time time
twoway (rarea coglb cogub time if ART == 1) ///
(rarea coglb cogub time if ART == 0) ///
(line cog time if ART == 0) ///
(line cog time if ART == 1) ///
, legend(label(3 "Planned natural conception") ///
label(4 "ART conception") col(1) ring(0) pos(11) order(4 3)) ///
ytitle("Average cognitive development") ///
xtitle(" ") xlabel(1(1)4, valuelabels) ///
note("{it:Note:} Shaded areas denote 95 % confidence intervals." ///
"{it:Source:} Millennium Cohort Study.", span) name(bands, replace)
Subscribe to:
Posts (Atom)

