The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use in Stata » Calculating median age at first sex
Calculating median age at first sex [message #6929] Tue, 04 August 2015 18:06 Go to next message
maras224 is currently offline  maras224
Messages: 2
Registered: August 2015
Member
I am trying to calculate median age at first sex, marriage, and birth in multiple countries and years.

I have succeeded in calculating age at first marriage and birth using the formula previously provided on this forum.( http://userforum.dhsprogram.com/index.php?t=msg&th=1337& amp;goto=2470&S=08c954804736d97c007deae6e959abed#msg_247 0)

An example of my working Stata code is below. However, when I attempt to calculate median age at first sex (v531), I am unable to replicate the numbers provided in published reports. I believe this may have to do with categories that may need to be excluded, such as 0 - Not had intercourse, 97 - inconsistent, or 98 - don't know.

Has anyone successfully replicated the published medians for age at first sex, and if so, how? Thanks for your help.

use "KEIR52FL.DTA", clear
svyset v021 [pweight=v005], strata(v023)

* Median age at first marriage
* Ages 20-29
tab v511 [iweight=v005/1000000] if v013 >= 2 & v013 <= 3, missing
scalar mafm2029 = 20 + (50-46.45)/(54.98-46.45)
scalar list mafm2029

Re: Calculating median age at first sex [message #6986 is a reply to message #6929] Fri, 07 August 2015 11:31 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member
Following is a response fron Senior DHS Specialist Sarah Bradley:


You are correct: the problem was those who have never had sex, code 0 in v531. If we use v531 as-is, we are treating all those who have not had sex as though they first had sex at age 0. Please try the code below which matches the results in the Kenya 2008-09 final report.

You should also note a minor issue in the code you shared. The weight used in your svyset command (which isn't used below) should be v005/1000000, not v005.

gen wt = v005/1000000
* Recode v531, setting those who've never had sex to missing
recode v531(0=.), g(age1sex)
* Ages 20-49
tab age1sex [iweight=wt] if v013 != 1, miss
scalar age1sex2049 = 18 + (50-47.77)/(60.85-47.77)
scalar list age1sex2049
Re: Calculating median age at first sex [message #7008 is a reply to message #6986] Mon, 10 August 2015 09:53 Go to previous message
maras224 is currently offline  maras224
Messages: 2
Registered: August 2015
Member
Thank you, Sarah. This was exactly what I needed to know. I was able to successfully replicate the published values for the three most recent surveys in Kenya and Zambia.
Previous Topic: Replicating DHS values
Next Topic: Need Help
Goto Forum:
  


Current Time: Fri Mar 29 09:27:57 Coordinated Universal Time 2024