The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Fertility » Stata code for mean duration of insusceptibility
Re: Stata code for mean duration of insusceptibility [message #13870 is a reply to message #11901] Tue, 16 January 2018 15:27 Go to previous messageGo to previous message
kbietsch is currently offline  kbietsch
Messages: 14
Registered: November 2015
Location: Washington, DC USA
Member

Has anyone written the stata code?

I have this for % postpartum amenorrhoeic, abstaining, and overall insusceptible

clear all
use GHKR72FL.DTA, clear

* age of child
gen months = v008-b3

* keeping young and droppin first of multipe births
keep if months <=35 & b0!=1

* //postpartum amenorrheic from most recent birth (midx=1).
gen ppa=.
replace ppa=1 if midx==1 & v405==1
replace ppa=0 if ppa==.
* //abstaining since most recent birth (midx=1).
gen abst=.
replace abst=1 if midx==1 & v406==1
replace abst=0 if abst==.
* // postpartum amenorrheic or abstaining since most recent birth (midx=1).
gen insus=.
replace insus=1 if midx==1 & (ppa==1 | abst==1)
replace insus=0 if insus==.

gen weight=v005/1000000
gen idnum = v021
gen statid =v022

svyset idnum [pw=weight], strata(statid) singleunit(scaled)

svy: mean ppa
svy: mean abst
svy: mean insus

************************************************************ ***********
To try and calculate mean time insusceptible, I referred to the Guide to DHS statistics

I assigned each person into their 2 month window and collapsed the data
gen month2=.

replace month2=0 if months==0 | months==1
replace month2=2 if months==2 | months==3
replace month2=4 if months==4 | months==5
replace month2=6 if months==6 | months==7
replace month2=8 if months==8 | months==9
replace month2=10 if months==10 | months==11
replace month2=12 if months==12 | months==13
replace month2=14 if months==14 | months==15
replace month2=16 if months==16 | months==17
replace month2=18 if months==18 | months==19
replace month2=20 if months==20 | months==21
replace month2=22 if months==22 | months==23
replace month2=24 if months==24 | months==25
replace month2=26 if months==26 | months==27
replace month2=28 if months==28 | months==29
replace month2=30 if months==30 | months==31
replace month2=32 if months==32 | months==33
replace month2=34 if months==34 | months==35

collapse (sum) ppa abst insus [aw=v005] , by(month2)

I then created a width variable:
gen width=.
replace width=.75 if _n==1
replace width=1.75 if _n==2
replace width= 2 if width==.

But like Bruno, I am still about 2 months lower than the report. Any ideas?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Assisted Reproductive Technology and multiple births
Next Topic: Vaginal rings for current contraception in V312
Goto Forum:
  


Current Time: Thu Nov 28 19:48:42 Coordinated Universal Time 2024