--------------------------------------------------------------------------------------------------------------------------------- name: log: C:\MaternalMortStats.log log type: text opened on: 11 Aug 2020, 19:17:21 . * Adult and maternal mortality counts - Trevor Croft - April 25, 2015 . . * This version applied to Indonesia DHS 2012 - Jan 3, 2016 . . use "NGIR6AFL.DTA", clear . . * keep only the variables needed . keep caseid v001 v002 v003 v005 v008 v011 v012 v013 awfactt mm* mmc* . . * Rename all of the repeating variables to drop the leading 0 to help with reshaping . rename mm*_0* mm*_* . . * Reshape the file into a sibling history file . * This will be slow to run and could take several minutes or more. . reshape long mmidx_ mm1_ mm2_ mm3_ mm4_ mm5_ mm6_ mm7_ mm8_ mm9_ mm10_ mm11_ mm12_ mm13_ mm14_ mm15_, i(caseid) j(mmindex) (note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) Data wide -> long ----------------------------------------------------------------------------- Number of obs. 38948 -> 778960 Number of variables 340 -> 37 j variable (20 values) -> mmindex xij variables: mmidx_1 mmidx_2 ... mmidx_20 -> mmidx_ mm1_1 mm1_2 ... mm1_20 -> mm1_ mm2_1 mm2_2 ... mm2_20 -> mm2_ mm3_1 mm3_2 ... mm3_20 -> mm3_ mm4_1 mm4_2 ... mm4_20 -> mm4_ mm5_1 mm5_2 ... mm5_20 -> mm5_ mm6_1 mm6_2 ... mm6_20 -> mm6_ mm7_1 mm7_2 ... mm7_20 -> mm7_ mm8_1 mm8_2 ... mm8_20 -> mm8_ mm9_1 mm9_2 ... mm9_20 -> mm9_ mm10_1 mm10_2 ... mm10_20 -> mm10_ mm11_1 mm11_2 ... mm11_20 -> mm11_ mm12_1 mm12_2 ... mm12_20 -> mm12_ mm13_1 mm13_2 ... mm13_20 -> mm13_ mm14_1 mm14_2 ... mm14_20 -> mm14_ mm15_1 mm15_2 ... mm15_20 -> mm15_ ----------------------------------------------------------------------------- . . * Rename to drop the trailing underscore on the end of the reshaped variables . rename mm*_ mm* . . * Drop empty entries . drop if mmidx==. (570636 observations deleted) . . * Check total sisters and brothers - compare total from table 15.1 . tab mm1 mm1 | Freq. Percent Cum. ------------+----------------------------------- male | 107,188 51.45 51.45 female | 100,877 48.42 99.88 9 | 259 0.12 100.00 ------------+----------------------------------- Total | 208,324 100.00 . . * Drop siblings without sex or survival status . drop if (mm1 == 8 | mm1 == 9 | mm2 == 8 | mm2 == 9 | mm1 == . | mm2 == .) (405 observations deleted) . . * Check counts of sisters and brothers by survival status - compare with living siblings and dead siblings from table 15.1 . tab mm2 mm1 | mm1 mm2 | male female | Total -----------+----------------------+---------- dead | 16,719 14,746 | 31,465 alive | 90,389 86,065 | 176,454 -----------+----------------------+---------- Total | 107,108 100,811 | 207,919 . . . * Period to use . * 7 years (84 months) before interview or 5 years (60 months) . local period 60 . . * Calculate deaths and exposure for each age group. Each woman can contribute to up to 3 different age groups in the past 7 ye > ars. . . * Calculate upper and lower limits in CMC for inclusion for time period. Exclude month of interview. . gen upplim = v008-1 . * replace upper limit with CMC date of death for siblings that died . replace upplim = mm8 if mm2 == 0 (31462 real changes made) . * lower limit - 7 years (84 months) before interview or 5 years (60 months) . gen lowlim = v008-`period' . * Total exposure in the time period . gen exposure = upplim-lowlim+1 . replace exposure = 0 if exposure < 0 (27696 real changes made) . . * Oldest age group . gen agegrp1 = int((upplim-mm4)/60) . * Calculate exposure in this age group . gen expo1 = min(exposure,upplim - (mm4 + agegrp1*60) + 1) . * Calculate deaths . gen deaths1 = (mm2==0 & expo1 > 0) . * Calculate remaining exposure time . replace exposure = exposure - expo1 (180219 real changes made) . . * Middle age group . gen agegrp2 = agegrp1 - 1 . * Calculate exposure in this age group . gen expo2 = min(60,exposure) . * Set deaths to 0 - all deaths are in the oldest age group . gen deaths2 = 0 . * Calculate remaining exposure time . replace exposure = exposure - expo2 (178903 real changes made) . . * Youngest age group . gen agegrp3 = agegrp2 - 1 . * Calculate exposure in this age group . gen expo3 = min(60,exposure) . * Set deaths to 0 - all deaths are in the oldest age group . gen deaths3 = 0 . . * Reshape so that there are separate records for each age group with exposure and eaths in those age groups . reshape long agegrp expo deaths, i(caseid mmindex) j(j) (note: j = 1 2 3) Data wide -> long ----------------------------------------------------------------------------- Number of obs. 207919 -> 623757 Number of variables 49 -> 44 j variable (3 values) -> j xij variables: agegrp1 agegrp2 agegrp3 -> agegrp expo1 expo2 expo3 -> expo deaths1 deaths2 deaths3 -> deaths ----------------------------------------------------------------------------- . . * Only keep the deaths and exposure in age groups 3 (15-19) through 9 (45-49) . keep if agegrp >= 3 & agegrp <= 9 (240014 observations deleted) . label define agegrp 3 "15-19" 4 "20-24" 5 "25-29" 6 "30-34" 7 "35-39" 8 "40-44" 9 " 45-49" . label values agegrp agegrp . . * Sample weight . gen wt = v005/1000000 . . * Deaths from table 15.3 . tab agegrp mm1 [iw=deaths*wt ] | mm1 agegrp | male female | Total -----------+----------------------+---------- 15-19 | 102.83466 131.82835 | 234.66301 20-24 | 186.68044 175.84836 | 362.5288 25-29 | 174.25987 243.43821 | 417.69808 30-34 | 167.48914 167.12022 | 334.60936 35-39 | 186.8113 163.81114 | 350.62244 40-44 | 127.35212 113.77286 | 241.12498 45-49 | 91.294378 71.4038021 | 162.69818 -----------+----------------------+---------- Total | 1,036.722 1,067.223 | 2,103.945 . * Exposure from table 15.3 (expo is in months, division by 12 to give years) . tab agegrp mm1 [iw=expo*wt/12] | mm1 agegrp | male female | Total -----------+----------------------+---------- 15-19 | 61,326.88 58,574.35 | 119,901.2 20-24 | 70,190.54 66,572.47 |136,763.01 25-29 | 68,790.79 64,429.67 | 133,220.5 30-34 | 56,749.42 54,754.814 | 111,504.2 35-39 | 43,114.21 40,777.33 | 83,891.53 40-44 | 27,042.24 25,493.3 | 52,535.54 45-49 | 15,309.7 14,577.99 |29,887.691 -----------+----------------------+---------- Total | 342,523.8 325,179.9 | 667,703.7 . . . *GOT MY MATERNAL DEATHS FROM THIS . . * Deaths from table 15.4 - restict to maternal deaths . tab agegrp [iw=deaths*wt ] if mm1 == 2 & mm9 >= 2 & mm9 <= 6 agegrp | Freq. Percent Cum. ------------+----------------------------------- 15-19 | 42.2218733 12.31 12.31 20-24 | 81.2290903 23.68 35.99 25-29 | 80.1751656 23.37 59.36 30-34 | 44.3142764 12.92 72.28 35-39 | 57.239853 16.69 88.96 40-44 | 29.208759 8.51 97.48 45-49 | 8.64644009 2.52 100.00 ------------+----------------------------------- Total | 343.035458 100.00 . * Exposure from table 15.4 (expo is in months, division by 12 to give years) - restrict to women only . . . . . * EXPOSURE NUMBER OF YEARS BY AGE GROUP . tab agegrp [iw=expo*wt/12] if mm1 == 2 agegrp | Freq. Percent Cum. ------------+----------------------------------- 15-19 | 58,574.348 18.01 18.01 20-24 | 66,572.469 20.47 38.49 25-29 | 64,429.67 19.81 58.30 30-34 | 54,754.814 16.84 75.14 35-39 | 40,777.325 12.54 87.68 40-44 | 25,493.304 7.84 95.52 45-49 | 14,577.989 4.48 100.00 ------------+----------------------------------- Total | 325,179.92 100.00 . . *Distribution of respondents(Specific Age Group) in the Excel . tab v013 age in | 5-year | groups | Freq. Percent Cum. ------------+----------------------------------- 15-19 | 42,428 11.06 11.06 20-24 | 54,968 14.32 25.38 25-29 | 74,652 19.45 44.83 30-34 | 66,255 17.27 62.10 35-39 | 61,316 15.98 78.08 40-44 | 46,241 12.05 90.13 45-49 | 37,883 9.87 100.00 ------------+----------------------------------- Total | 383,743 100.00 . . save "C:\MatMortScript.dta" file C:\MatMortScript.dta saved . . log close name: log: C:\MaternalMortStats.log log type: text closed on: 11 Aug 2020, 19:17:39 ---------------------------------------------------------------------------------------------------------------------------------