The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Nepal » Replicating table 8.4- Nepal DHS 2011
Re: Replicating table 8.4- Nepal DHS 2011 [message #8653 is a reply to message #8651] Tue, 24 November 2015 20:28 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 697
Registered: January 2013
Senior Member
I realized that I could get you on the right track fairly easily. Here is code to reshape Nepal 2001 pregnancy history data into a file of pregnancies
* Open the Nepal 2001 dataset
use "C:\Data\DHS_Stata\NPIR41FL.DTA", clear

* keep just a set of useful variables.  If you keep too many this process gets really really slow and may fail due to memory
keep caseid v001 v002 v003 v005 v008 v011 v013 v017 v018 v019 v021 v022 v023 ///
  idx92_* bord9_* b0_92_* b1_92_* b2_92_* b3_92_* b4_92_* b5_92_* b6_92_* b7_92_* ///
  b8_92_* b9_92_* b10_9_* b11_9_* b12_9_* b13_9_* b16_9_* s216_* s217_* s227_* s228_* s229_*

* rename variables for reshaping
rename *_0* *_*
  
* reshape the pregnancy history into a filee of pregnancies
reshape long idx92_ bord9_ b0_92_ b1_92_ b2_92_ b3_92_ b4_92_ b5_92_ b6_92_ b7_92_ ///
  b8_92_ b9_92_ b10_9_ b11_9_ b12_9_ b13_9_ b16_9_ s216_ s217_ s227_ s228_ s229_, i(caseid) j(i)

* drop empty entries that contain no data
drop if idx92_==.  

* rename variables to easier names
rename *_92_ *  
rename *_9_ *  
rename idx92_ idx
rename bord9_ bord
rename  s*_ s*
* rename the b variables to p variables as these are for pregnancies and not for births, 
* just to avoid confusion with the birth history variables.
rename b* p*

* Restrict to all pregnancies in the last 5 years
keep if p3 > v008-60

* Check the results of the pregnancies
tab s227 s216 [iw=v005/1000000],m

* There are a couple of cases that seem inconsistent here.  Here is a suggestion for editing them:
* This case looks to have died on the first day rather than being a still birth
replace s216=1 if s227==. & s216==2
* This case looks to have been misrecorded as born died rather than lost before full term
replace s216=3 if s227==3 & s216==2

* To keep just the pregnancies of 7+ months duration, use the following:
keep if s227 == . | s227 >= 7
* I would then recode s216 into "born alive" and "stillbirth" (all of the others).
recode s216 (1=1 "Live birth")(2/3=2 "Stillbirth"), gen(type)

You can then rename and recode any variables you need to match the other files.

[Updated on: Wed, 25 November 2015 00:54]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Variable Construction
Next Topic: Table 2.11 Clarification
Goto Forum:
  


Current Time: Fri Jun 5 05:28:48 Eastern Daylight Time 2020