Following is a response from DHS staff member, Tom Pullum:
With DHS-8 data and the birth histories it is now much easier to calculate the perinatal mortality rate. I will paste below the Stata lines to do it, using the new GR file. It includes code for one covariate (wealth quintiles) and the total.
We have written new Stata code for Chapters 5 and 8 but it may not yet be posted on the GitHub site.
* Table 8.4 in Bangladesh 2022 DHS final report
* Use the GR file for DHS8 surveys
use "...BDGR81FL.DTA", clear
* Reduce the file to births and stillbirths in months 0-59 before the survey
keep if p19<60 & (p32==1 | p32==2)
gen wt=v005/1000000
* Construct the outcome variables
gen stillbirth=0
gen enn_death=0
replace stillbirth=1 if p32==2
replace enn_death=1 if p32==1 & p6<=106
replace stillbirth=stillbirth*wt
replace enn_death=enn_death*wt
gen case=wt
collapse (sum) stillbirth enn_death case, by(v190)
gen st_rate=1000*stillbirth/case
gen enn_rate=1000*enn_death/case
gen peri_rate=st_rate+enn_rate
gen ratio=stillbirth/enn_death
list, table clean
collapse (sum) stillbirth enn_death case
gen st_rate=1000*stillbirth/case
gen enn_rate=1000*enn_death/case
gen peri_rate=st_rate+enn_rate
gen ratio=stillbirth/enn_death
list, table clean