The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Reproductive Health » Variables of table 9.16 in Pakistan (Pregnancy outcomes)
Re: Variables of table 9.16 in Pakistan [message #26133 is a reply to message #26092] Fri, 10 February 2023 08:59 Go to previous messageGo to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 901
Registered: April 2022
Senior Member
Following is a response from DHS staff member, Tom Pullum:

The following program has some similarities to the one I posted to construct Table 9.16 but it gives the number of months with "P" before the month in which a birth, stillbirth, abortion, or miscarriage occurs. If the data are perfect, the month of conception will be the first month with a "P". However, the woman may not know when she actually became pregnant. It can happen that an abortion or miscarriage in the data is not preceded by ANY months with P. DHS would usually say that the duration of the pregnancy is one plus the number of preceding months of "P".

* Stata program to calculate the months pregnant (P) preceding BMAS codes.
* Illustrate with PKIR71FL.dta and all pregnancies in vcal_6.
* Refer to the outcomes generically as BMAS, for Births, Miscarriages, Abortions, Stillbirths
* Sequence them as in the table in the final report (Births, Stillbirths, Miscarriages, Abortions)
* An interval is censored if it is so close to the beginning of the calendar (the early months) that
* it is impossible to be sure of the number of preceding months of P's

************************************************************ ***************

program calc_interval_length

* Construct a file with a separate record for each BMAS
* We look for strings that end in B, C, A, or S and are preceded (chronologically) by P's
* Allow for possible codes C, A that are not preceded by P

* mbi: months as months before interview. mbi=col-v018
* cmc: months in century month codes. cmc=v017+80-col

keep v001 v002 v003 v005 v017 v018 vcal_6

* Calculate the number of P's that immediately precede the BMAS, allowing for 0 to 11
* Index the event by col, not cmc or mbi, and allow col to go from 1 to 79

* To reduce to events and intervals that are entirely included in the 60 months before the interview,
* in the loop below replace "80" with "60+v018"

quietly forvalues lcol=1/80 {
gen type_`lcol'=.
replace type_`lcol'=1 if substr(vcal_6,`lcol',1)=="B"
replace type_`lcol'=2 if substr(vcal_6,`lcol',1)=="S"
replace type_`lcol'=3 if substr(vcal_6,`lcol',1)=="C"
replace type_`lcol'=4 if substr(vcal_6,`lcol',1)=="A"
gen     interval_`lcol'= .
replace interval_`lcol'= 0 if                                  substr(vcal_6,`lcol'+1,1)~="P"  & `lcol'+1<=80
replace interval_`lcol'= 1 if substr(vcal_6,`lcol'+1,1) =="P" & substr(vcal_6,`lcol'+2,1)~="P"  & `lcol'+2<=80
replace interval_`lcol'= 2 if substr(vcal_6,`lcol'+1,2) =="PP" & substr(vcal_6,`lcol'+3,1)~="P"  & `lcol'+3<=80
replace interval_`lcol'= 3 if substr(vcal_6,`lcol'+1,3) =="PPP" & substr(vcal_6,`lcol'+4,1)~="P"  & `lcol'+4<=80
replace interval_`lcol'= 4 if substr(vcal_6,`lcol'+1,4) =="PPPP" & substr(vcal_6,`lcol'+5,1)~="P"  & `lcol'+5<=80
replace interval_`lcol'= 5 if substr(vcal_6,`lcol'+1,5) =="PPPPP" & substr(vcal_6,`lcol'+6,1)~="P"  & `lcol'+6<=80
replace interval_`lcol'= 6 if substr(vcal_6,`lcol'+1,6) =="PPPPPP" & substr(vcal_6,`lcol'+7,1)~="P"  & `lcol'+7<=80
replace interval_`lcol'= 7 if substr(vcal_6,`lcol'+1,7) =="PPPPPPP" & substr(vcal_6,`lcol'+8,1)~="P"  & `lcol'+8<=80
replace interval_`lcol'= 8 if substr(vcal_6,`lcol'+1,8) =="PPPPPPPP" & substr(vcal_6,`lcol'+9,1)~="P"  & `lcol'+9<=80
replace interval_`lcol'= 9 if substr(vcal_6,`lcol'+1,9) =="PPPPPPPPP" & substr(vcal_6,`lcol'+10,1)~="P" & `lcol'+10<=80
replace interval_`lcol'=10 if substr(vcal_6,`lcol'+1,10)=="PPPPPPPPPP" & substr(vcal_6,`lcol'+11,1)~="P" & `lcol'+11<=80
replace interval_`lcol'=11 if substr(vcal_6,`lcol'+1,11)=="PPPPPPPPPPP" & substr(vcal_6,`lcol'+12,1)~="P" & `lcol'+12<=80
}

reshape long type_ interval_, i(v001 v002 v003) j(col)
rename *_ *

drop if type==.
label variable type "Type of pregnancy outcome"
label define type 1 "Live birth" 2 "Stillbirth" 3 "Miscarriage" 4 "Abortion"
label values type type

label variable interval "Preceding months of P"
replace interval=99 if interval==.
label define interval 99 "Censored"
label values interval interval

tab interval type
tab interval type [iweight=v005/1000000]

save PK71_BMAS_months_pregnant.dta, replace

end

***************************************************************************
***************************************************************************
***************************************************************************
***************************************************************************
* Execution begins here

* Specify a workspace
cd e:\DHS\programs\calendar_and_discontinuation

********************************
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\PKIR71FL.DTA" , clear
* In this survey the BMAS are in vcal_6; C is the symbol for Miscarriage 
********************************

calc_interval_length


Here is the unweighted table:

Preceding |
months of |          Type of pregnancy outcome
         P | Live birt  Stillbirt  Miscarria   Abortion |     Total
-----------+--------------------------------------------+----------
         0 |         0          0        315         70 |       385 
         1 |         0          0        786         95 |       881 
         2 |         0          0        684         49 |       733 
         3 |         0          0        266         19 |       285 
         4 |         0          0        128         10 |       138 
         5 |         0          0         73          2 |        75 
         6 |        67         71          0          0 |       138 
         7 |       181         89          0          0 |       270 
         8 |    13,007        172          0          0 |    13,179 
         9 |        13          0          0          0 |        13 
  Censored |     1,581         45         49          7 |     1,682 
-----------+--------------------------------------------+----------
     Total |    14,849        377      2,301        252 |    17,779

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Community-Level variables with SPSS
Next Topic: Pregnant Women 5 years preceding the survey
Goto Forum:
  


Current Time: Wed Dec 11 12:04:53 Coordinated Universal Time 2024