Replicating table 9.18 [message #13472] |
Tue, 07 November 2017 17:50 |
Sami
Messages: 27 Registered: May 2016 Location: Nepal
|
Member |
|
|
Dear DHS,
I am trying to replicate Nepal DHS 2011 table 9.18.
I used the following command as explained in the previous thread. However, i found hard to separate abortion.
use "C:\Data\DHS_Stata\NPIR60FL.DTA" , clear
gen pregs = 0
forvalues i = 1/80 {
gen cmc`i' = v017 + 80 - `i'
gen event`i' = substr(vcal_1, `i', 1)
gen type`i' = .
replace type`i' = 1 if substr(vcal_1,`i',1) == "B"
replace type`i' = 3 if substr(vcal_1,`i',1) == "T"
replace type`i' = 2 if substr(vcal_1,`i',7) == "TPPPPPP"
replace pregs = pregs+1 if (substr(vcal_1,`i',1) == "B" | substr(vcal_1,`i',1) == "T")
}
* Drop cases with no pregnancies
drop if pregs == 0
* Decide what variables you want to keep first before the reshape, modify this list as you need to add extra variables.
keep caseid v001 v002 v003 v005 v008 v011 v013 v017 v018 v019 v021 v022 v023 cmc* event* type*
* The reshape is really really really slow if you don't select variables and cases first, and will most likely fail otherwise.
reshape long cmc event type, i(caseid) j(ix)
lab def type 1 "Birth" 2 "Stillbirth" 3 "Miscarriage/abortion"
lab val type type
lab var type "Type of pregnancy"
lab var cmc "Century month code of event"
lab var event "Calendar event code"
* Set length of calendar to use
gen callen = v018 + 59
* If calendar is aligned right (as in original dataset), use the following:
gen beg = v018
gen end = callen
* If calendar is aligned left (as it is in some datasets), use the following:
*gen beg = 1
*gen end = 60
* Include only the five year period
keep if ix >= beg & ix <= end
* check the pregnancy types
tab type [iw=v005/1000000]
Any assistance would be great.
Thank you
Sammy
|
|
|
Re: Replicating table 9.18 [message #13614 is a reply to message #13472] |
Wed, 29 November 2017 11:40 |
Trevor-DHS
Messages: 802 Registered: January 2013
|
Senior Member |
|
|
See vcal_6. In this variable for each month in which you see a "T" in vcal_1, you will find code "A" (abortion), "S" (stillbirth), and "C" miscarriage, that can be used to break out the abortions.
|
|
|