Home » Countries » Nepal » Replicating table 8.4- Nepal DHS 2011
Re: Replicating table 8.4- Nepal DHS 2011 [message #8646 is a reply to message #8642] |
Tue, 24 November 2015 19:19 |
Trevor-DHS
Messages: 789 Registered: January 2013
|
Senior Member |
|
|
The following code reshapes the IR dataset into pregnancies and keeps pregnancies of 7 months duration.
* Using Nepal DHS 2011
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]
* Note that this will not match the 5444 pregnancies of 7+ months as that includes twins.
* This file excludes twins, but i believe that is what you really need.
* keep only births and stillbirths
keep if type == 1 | type == 2
Note that this excludes twins so it does not match the 5444, but I think this is actually more useful for your needs.
|
|
|
|
|
Replicating table 8.4- Nepal DHS 2011
By: pramesh on Thu, 19 November 2015 21:05
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: Liz-DHS on Fri, 20 November 2015 16:11
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Fri, 20 November 2015 16:37
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Fri, 20 November 2015 22:16
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Sat, 21 November 2015 16:54
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Sun, 22 November 2015 18:32
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Sun, 22 November 2015 20:08
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Mon, 23 November 2015 04:38
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Mon, 23 November 2015 18:23
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Mon, 23 November 2015 19:02
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Mon, 23 November 2015 19:40
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 24 November 2015 03:58
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 24 November 2015 19:44
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 24 November 2015 23:49
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Wed, 25 November 2015 00:42
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Wed, 25 November 2015 01:38
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 01 December 2015 01:58
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Thu, 03 December 2015 15:55
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: Liz-DHS on Mon, 25 January 2016 15:12
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 26 January 2016 17:04
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Wed, 27 January 2016 05:42
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 05 April 2016 20:12
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Tue, 24 November 2015 19:43
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Wed, 25 November 2015 23:22
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Thu, 26 November 2015 05:02
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Thu, 26 November 2015 17:43
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: Liz-DHS on Wed, 02 December 2015 09:45
|
|
|
Re: Replicating table 8.4- Nepal DHS 2011
By: pramesh on Fri, 27 November 2015 18:26
|
Goto Forum:
Current Time: Tue Apr 23 07:01:51 Coordinated Universal Time 2024
|