* do e:\DHS\India\in_school_do_21Feb2018.txt * This routine concerns the calculation of school attendance * It specifically attempts to replicate the indicator in table 2.9 in * the India 2005-06 report but the indicator is also used in table 2.19 * in the India 2015-16 report set more off ***************************************************** program define replicate_table * confirm that I can construct table 2.9 using sh18c set more off use e:\DHS\DHS_data\PR_files\IAPR52FL.dta, clear * L and H are the low and high ends of the age range, in years, at the beginning * of the school age gen sexur=hv025+2*(hv104-1) tab hv025 hv104, summarize(sexur) scalar L=6 scalar H=17 gen in_school=. replace in_school=0 if hv103==1& sh18c>=L*12 & sh18c<=H*12+11 replace in_school=100 if in_school==0 & (hv121==1 | hv121==2) tab sexur [iweight=hv005], summarize(in_school) means noobs end ***************************************************** program define prepare_for_merge * Check how to construct sh18c * We can get year and month of birth for * children in the BR file * women in the IR file * men in the MR file * Otherwise we only have hv105 to work with * Prepare IR file for merge use e:\DHS\DHS_data\IR_files\IAIR52FL.dta, clear keep v024 v001 v002 v003 v011 v024 gen in_IR=1 rename v024 hv024 rename v001 hv001 rename v002 hv002 rename v003 hvidx sort hv024 hv001 hv002 hvidx save e:\DHS\DHS_data\scratch\IAIRtemp.dta, replace * Prepare MR file for merge use e:\DHS\DHS_data\MR_files\IAMR52FL.dta, clear keep mv024 mv001 mv002 mv003 mv011 mv024 gen in_MR=1 rename mv024 hv024 rename mv001 hv001 rename mv002 hv002 rename mv003 hvidx sort hv024 hv001 hv002 hvidx save e:\DHS\DHS_data\scratch\IAMRtemp.dta, replace * Prepare BR file for merge use e:\DHS\DHS_data\BR_files\IABR52FL.dta, clear keep v024 v001 v002 b16 b1 b2 b3 gen in_BR=1 rename v024 hv024 rename v001 hv001 rename v002 hv002 rename b16 hvidx sort hv024 hv001 hv002 hvidx save e:\DHS\DHS_data\scratch\IABRtemp.dta, replace * Prepare PR file for merge use e:\DHS\DHS_data\PR_files\IAPR52FL.dta, clear keep hv024 hv001 hv002 hvidx hv005 hv006 hv007 hv008 hv024 hv025 hv101-hv105 hv111 hv113 hv121 sh18c gen in_PR=1 sort hv024 hv001 hv002 hvidx save e:\DHS\DHS_data\scratch\IAPRtemp.dta, replace end ***************************************************** program define merge_files use e:\DHS\DHS_data\scratch\IAPRtemp.dta, clear * Merge with BR merge hv024 hv001 hv002 hvidx using e:\DHS\DHS_data\scratch\IABRtemp.dta rename _merge _merge_PR_BR tab1 in_*,m drop if in_PR==. sort hv024 hv001 hv002 hvidx * Merge with IR merge hv024 hv001 hv002 hvidx using e:\DHS\DHS_data\scratch\IAIRtemp.dta rename _merge _merge_PR_IR tab1 in_*,m drop if in_PR==. sort hv024 hv001 hv002 hvidx * Merge with MR merge hv024 hv001 hv002 hvidx using e:\DHS\DHS_data\scratch\IAMRtemp.dta rename _merge _merge_PR_MR tab1 in_*,m drop if in_PR==. sort hv024 hv001 hv002 hvidx gen cmc_of_birth=. replace cmc_of_birth=b3 if in_BR==1 replace cmc_of_birth=v011 if in_IR==1 replace cmc_of_birth=mv011 if in_MR==1 save e:\DHS\India\merged_file.dta, replace end ***************************************************** program define confirm_indicator * set the scalar for the cmc of the month that is crucial for school attendance * April 2005: 4+12*(2005-1900) = 1264 * sh18c is months of age in month CMC. use e:\DHS\India\merged_file.dta, clear gen CMC=4+12*(2005-1900) gen must_use_hv105=0 replace must_use_hv105=1 if in_BR==. & in_IR==. & in_MR==. gen sh18c_test=CMC-cmc_of_birth * must remove negative values for children born AFTER CMC replace sh18c_test=. if in_BR==1 & b3>CMC regress sh18c_test sh18c if in_BR==1 regress sh18c_test sh18c if in_IR==1 regress sh18c_test sh18c if in_MR==1 replace sh18c_test=12*hv105-6 if must_use_hv105==1 * must remove negative values replace sh18c_test=. if must_use_hv105==1 & sh18c_test<0 regress sh18c_test sh18c if must_use_hv105==1 regress sh18c_test sh18c if must_use_hv105==0 regress sh18c_test sh18c * Replicate with estimated values of sh18c gen sexur=hv025+2*(hv104-1) tab hv025 hv104, summarize(sexur) scalar L=6 scalar H=17 gen in_school=. replace in_school=0 if hv103==1& sh18c_test>=L*12 & sh18c_test<=H*12+11 replace in_school=100 if in_school==0 & (hv121==1 | hv121==2) tab sexur [iweight=hv005], summarize(in_school) means noobs end ***************************************************** ***************************************************** ***************************************************** ***************************************************** ***************************************************** * EXECUTION BEGINS HERE *replicate_table prepare_for_merge merge_files confirm_indicator