The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Mortality » Survival status of preceding birth (Requesting stata code for survival status of preceding birth)
Re: Survival status of preceding birth [message #25364 is a reply to message #25342] Wed, 12 October 2022 12:17 Go to previous messageGo to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 893
Registered: April 2022
Senior Member
Following is a response from DHS staff member Tom Pullum:

Your question is outside the range of the DHS users forum but I already had a program to merge successive siblings and I just needed to adapt it for your purposes. I have modified your outcome variable, but just by omitting cases of type 3. Because most deaths occur at a very early age, there are many more cases of type 1 than of type 2.

* Program to construct pairs of children, a reference child plus next earlier sibling
* This example does not include the mother's variables

* b3 is cmc of birth

* b7 is (imputed) months of age at death.

* b11 is the interval between the two siblings, in months

* Specify a path to a workspace
cd e:\DHS\DHS_data\scratch

use v001 v002 v003 v008 b* using "...BDBR7RFL.DTA", clear

* To get b7r, add 6 months if b7 is >=24 and a multiple of 12.
* Do not change if the change would be later than the date of interview.
gen b7r=b7
replace b7r=b7+6 if b7>=24 & b7==12*int(b7/12) & b7+6<v008

egen sibsize=count(bidx),by(v001 v002 v003)

* construct two files, one for the younger child in a pair and one for the older child
sort v001 v002 v003 bidx
save temp_younger.dta, replace

rename b* b*_sib

* attach the child with bidx=2 to the child with bidx=1
* attach the child with bidx=3 to the child with bidx=2
* etc.

gen bidx=bidx_sib-1

sort v001 v002 v003 bidx
merge v001 v002 v003 bidx using temp_younger.dta
tab _merge

* the child with bidx=1 does not get attached to a younger sibling
* the child with bidx=sibsize does not get attached to an older sibling
* remove these two types of cases
drop if bidx==0 | bidx_sib==.

tab _merge
drop _merge

keep v001 v002 v003 bidx* b0* b3* b4* b5* b7* b11

gen sib_died=.
replace sib_died=0 if b5_sib==1
replace sib_died=1 if b5_sib==0 & b3_sib+b7r_sib<b3-9
replace sib_died=2 if b5_sib==0 & b3_sib+b7r_sib>=b3-9

label variable sib_died "Outcome for younger sib"
label define sib_died 0 "Alive" 1 "Died before" 2 "Died after"
label values sib_died sib_died

* "before" and "after" are relative to the month of conception of the reference child

order v001 v002 v003 bidx* b0* b3* b4* b5* b7_sib b7r_sib sib_died

list v001 v002 v003 bidx* b0* b3* b4* b7_sib b7r_sib b11 sib_died if _n<=50, table clean compress
tab sib_died

* save with some filename and then merge with the BR or KR file to get weights and other variables
 
Read Message
Read Message
Read Message
Previous Topic: Effect of Fertility decline on Maternal Mortality
Next Topic: How to convert Afghan Dates to Gregorian calendar -SAS
Goto Forum:
  


Current Time: Sat Nov 30 02:28:57 Coordinated Universal Time 2024