* do e:\DHS\programs\calendar_and_discontinuation\IA7E_calendar_do_31Oct2024.txt * Stata program to construct table 6.15 in the final report on the NFHS-5 * Table gives the outcome of the most recent pregnancy in the past 5 years. *************************************************************************** program define calendar_BT * Calendar approach using BT, with T not broken down into MAS * mbi: months as months before interview. mbi=col-v018 * cmc: months in century month codes. cmc=v017+80-col use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\IAIR7EFL.DTA" , clear keep v001 v002 v003 v005 v008 v017 v018 v023 v024 v025 v130 v133 v190 v231 s116 s234 vcal_1 b3_01 * Keep variables needed for table 6.15, not just the variables needed for the outcome * B and T are in vcal_1 * Read vcal_1 from left to right, i.e. going back in time from the month of interview. * Save the column number of the first B or T as BT_col * BT_type is 1 for B, 2 for T local lcol=1 * BT_col is the column of the most recent appearance of B or T gen BT_col=0 quietly while `lcol'<=80 { replace BT_col=`lcol' if BT_col==0 & (substr(vcal_1,`lcol',1)=="B" | substr(vcal_1,`lcol',1)=="T") local lcol=`lcol'+1 } * BT_type is 1 for B or 2 for T gen BT_type=. replace BT_type=1 if substr(vcal_1,BT_col,1)=="B" replace BT_type=2 if substr(vcal_1,BT_col,1)=="T" label define BT_type 1 "B" 2 "T" label values BT_type BT_type * Convert the date to cmc gen BT_cmc=v017+80-BT_col * Restrict to the past 60 months tab BT_type if v008-BT_cmc<60 [iweight=v005/1000000] end *************************************************************************** program define b3_v231_s234 use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\IAIR7EFL.DTA" , clear keep v001 v002 v003 v005 v008 v018 v023 v024 v025 v130 v133 v190 s116 v231 s234 b3_01 b19_01 * Keep variables needed for table 6.15, not just the variables needed for the outcome * v231 is cmc of last pregnancy termination (that was not a live birth) * s234 is termination type MAS (if not a live birth) * b3_01 is cmc of last live birth * construct a new variable that is termination type of most recent pregnancy, BMAS_type * and a new variable that is termination cmc of most recent pregnancy, BMAS_cmc * birth (B) is BMAS_type=0 * if the sequence is birth B, termination MAS, survey: BMAS_type is s234 and BMAS_cmc is v231 * same if there was no birth * if the sequence is termination, birth, survey: BMAS_type is B=0 and BMAS_cmc is b3_01 * same if there was no termination * Not clear where the = sign should go. * It is possible that for a multiple birth one child is born alive and one is a stillbirth. * Do not expect an exact match because I don't know how ambiguities were handled. * The cmc of the most recent birth is not limited to (for example) the past 5 years; * can go back in time indefinitely; NA if not in the past 5 years * numerical BMAS (weighted) implied by table 6.15) scalar n=255549 scalar pb=.889 scalar pm=.073 scalar pa=.029 scalar ps=.009 scalar pt=pm+pa+ps scalar nb=n*pb scalar nm=n*pm scalar na=n*pa scalar ns=n*ps scalar nt=n*pt scalar list pb pm pa ps pt n scalar list nb nm na ns nt n * Restrict to the past 60 months replace b3_01=. if b19_01>=60 replace v231=. if v008-v231>=60 | v008-v231<0 replace s234=. if v231==. gen BMAS_cmc=. gen BMAS_type=. * There was a birth but not a termination. Latest pregnancy is latest birth. replace BMAS_cmc=b3_01 if b3_01<. & s234==. replace BMAS_type =0 if b3_01<. & s234==. * There was a termination but not a birth. Latest pregnancy is latest termination. replace BMAS_cmc =v231 if v231<. & b3_01==. replace BMAS_type=s234 if v231<. & b3_01==. * There was both a birth and a termination * Most recent termination was before the most recent birth. Latest pregnancy is latest birth. replace BMAS_cmc=b3_01 if b3_01<. & v231