* do e:\DHS\India\fert_planning_do_26Feb2018.txt * Calculate fertility planning status table, 4.18, for India 2015-16 DHS, NFHS-4 log using e:\DHS\India\fert_planning_log_26Feb2018, replace set more off ************************************************************ program define reduce_IR_file use e:\DHS\DHS_data\IR_files\IAIR71FL.dta, clear keep caseid v005 v008 v011 bord_01-bord_06 b3_01-b3_06 m10_1-m10_6 v201 v213 v214 v225 * v213 V213 currently pregnant * v225 V225 current pregnancy wanted * v226 V226 time since last period (comp) (months) gen womanid=_n rename *_0* *_* save e:\DHS\DHS_data\scratch\IAIR71temp.dta, replace end ************************************************************ program define reshape_births use e:\DHS\DHS_data\scratch\IAIR71temp.dta, clear * construct a file of births in the past five years reshape long bord_ b3_ m10_, i(womanid) j(bidx) drop if b3==. rename *_ * gen interval=v008-b3 keep if interval<60 drop interval gen age_at_birth=-2 + int((b3-v011)/60) replace age_at_birth=1 if age_at_birth<1 label define age_at_birth 1 "<20" 2 "20-24" 3 "25-29" 4 "30-34" 5 "35-39" 6 "40-44" 7 "45-49" label values age_at_birth age_at_birth tab age_at_birth,m save e:\DHS\DHS_data\scratch\IAIR71temp_births.dta, replace end ************************************************************ program define append_current_preg * construct a file of pregnancies use e:\DHS\DHS_data\scratch\IAIR71temp.dta, clear keep caseid v005 v008 v011 v201 v213 v214 v225 keep if v213==1 rename v225 m10 gen bidx=0 * if the woman is currently pregnant, set the birth order of the pregnancy gen bord=v201+1 tab v214,m gen preg_duration=v214 * Note: there are 75 women who report themselves in the 10th month of pregnancy. * Such women SHOULD BE grouped with the 9th month. However, in order to match * table 4.18, we must skip that step, in effect saying that the child will be * born THE MONTH BEFORE the interview!! *replace preg_duration=9 if v214>9 * Also there are 7 women for whom duration of current pregnancy is missing. For * that reason, the total of the number of births under "mother's age at birth" * in table 4.18 is short by 7 births. gen cmc_preg_delivery=v008+(9-preg_duration) gen age_at_birth=-2 + int((cmc_preg_delivery-v011)/60) *gen months_preg=v226 *replace months_preg=9 if v226>9 *gen b3=v008+(9-months_preg) save e:\DHS\DHS_data\scratch\IAIR71temp_pregs.dta, replace append using e:\DHS\DHS_data\scratch\IAIR71temp_births.dta gen birth_order=bord replace birth_order=4 if bord>4 save e:\DHS\DHS_data\scratch\IAIR71temp_births_plus_pregs.dta, replace end ************************************************************ program define calculate_table use e:\DHS\DHS_data\scratch\IAIR71temp_births_plus_pregs.dta, clear tab birth_order [iweight=v005/1000000] tab age_at_birth [iweight=v005/1000000] end ************************************************************ ************************************************************ ************************************************************ ************************************************************ * EXECUTION BEGINS HERE reduce_IR_file reshape_births append_current_preg calculate_table