* This program shows how to convert wm.dta and bh.dta from a MICS survey * to a pseudo-IR file for calculation of fertility rates. * Illustrated with Malawi 2019 MICS. The variable names may not always be the same. * You may want to save covariates in wm.dta scalar sdatapath="e:\DHS\DHS_data\MICS_data\Malawi_2019" local ldatapath=sdatapath cd `ldatapath' * Prepare the women's file use wm.dta, clear gen v001=WM1 gen v002=WM2 gen v003=WM3 gen v005=round(1000000*wmweight) gen v008=WDOI gen v011=WDOB gen v023=stratum gen v201=CM11 keep v* sort v001 v002 v003 save wm_workfile.dta, replace * Prepare the children's file use bh.dta, clear gen v001=WM1 gen v002=WM2 gen v003=WM3 * brthord in the bh file is categorized and cannot be used gen bord=BH0 gen b3=BH4C keep v* bord b3 sort v001 v002 v003 save bh_workfile.dta, replace merge v001 v002 v003 using wm_workfile.dta * Women in wm.dta with and without children must be treated * separately; otherwise the reshape command will not work tab _merge save temp.dta, replace * Women with _merge=2 are childless keep if _merge==2 drop _merge save IR_with_no_children.dta, replace * Return to these women later * Women with _merge=3 have 1+ children use temp.dta keep if _merge==3 drop _merge * Construct bidx from v201 and bord gen bidx=v201+1-bord drop bord rename b3 b3_ reshape wide b3_, i(v001 v002 v003) j(bidx) save IR_with_children.dta, replace append using IR_with_no_children.dta * for the women with no children, b3_1, etc., will be defined and set to . * Optional: as with DHS data, put a leading 0 in front of index values 1-9 forvalues ll=1/9 { rename b3_`ll' b3_0`ll' } drop bord b3 order v* b* sort v001 v002 v003 save IR.dta, replace