* select cases and variables of interest from the birth history
use "ETBR41FL.DTA", clear
keep caseid v001 v002 v003 v005 v008 v011 v013 v017 v018 v019 v021 v022 v023 b3 b6
* keep births in the last 5 years
keep if b3 > v008-60
save births, replace
* select cases and variables of interest from the non-live pregnancy history
use "ETIR41FL.DTA", clear
keep caseid v001 v002 v003 v005 v008 v011 v013 v017 v018 v019 v021 v022 v023 s231ac_* s231c_*
* convert to long format to match birth history
reshape long s231ac_ s231c_, i(caseid) j(i)
* keep only pregnancies in the last 5 years of 7 month duration or longer
drop if s231ac_==.
keep if s231ac_ > v008-60 & s231c_ >=7 & s231c_ != .
* rename cmc date of pregnancy to match birth history
rename s231ac_ b3
* combine births and non-live pregnancies of 7+ months
append using births
* set weight variable
gen wt = v005/1000000
* capture stillbirths - those with a duration of pregnancy in s231c_
gen stillbirth = (s231c_ != .)
tab stillbirth [iw=wt]
* capture early neonatal deaths (deaths in the first 7 days [0-6] = b6 < 107)
gen earlyneonatal = (b6 < 107)
tab earlyneonatal [iw=wt]
* perinatal mortality is stillbirths or early neonatal deaths
gen perinatal = (stillbirth | earlyneonatal)
tab perinatal [iw=wt]
This shows 234 stillbirths, 421 early neonatal deaths, and a perinatal mortality rate of 5.25 percent, equivalent to 52.5 per thousand (the last digit is slightly different and I don't have an explanation why).