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 and percentage of respondents with sex before the age of 15
Re: Calculating median age at first sex and percentage of respondents with sex before the age of 15 [message #12912 is a reply to message #11972] Mon, 07 August 2017 02:10 Go to previous messageGo to previous message
cmhabito is currently offline  cmhabito
Messages: 4
Registered: June 2017
Member
Hello,

I have been using the individual woman's dataset from the Philippines NDHS 2013, and am having some trouble replicating the median age at first sex by age group (Table 4.5) that appear in the final report. I have been using Stata 14 to analyze the data, and have read the relevant threads on this user forum (http:// userforum.dhsprogram.com/index.php?t=msg&th=5960&sta rt=0& and http:// userforum.dhsprogram.com/index.php?t=msg&th=1337&got o=2470&S=08c954804736d97c007deae6e959abed#msg_2470), but have still not had any luck generating the same values that appear in the final report. My Stata code is as follows:

*** Survey design
gen weight = v005/1000000
svyset [pweight = weight], psu(v021) strata(v023)

*** First, checking the percent distribution of age at first sex for women 25-49 years old:
svy: tab v531, obs percent format(%9.1f) // v531 is age at first sex (imputed)

*** Computing for median age at first sex for respondents 25-49 years old, Option A:
_pctile v531 if v012 > 24 & v012 < 50 [pweight = weight], p(50) // v012 is current age of respondent
return list // returns median = 20

// OR

*** Computing for median age at first sex for respondents 25-49 years old, Option B:
summarize v531 if v012 > 24 & v012 < 50 [aweight = weight], detail // returns median = 20

According to Table 4.5 in the Philippines NDHS 2013 final report, the median age at first sex for this age group should be 21.5.

Could you please help me figure out the reason why I am not generating the correct median value? I am not sure if it has to do with my code or with the variables I am using (or both), but I would appreciate any help you could offer.

Thank you!

Cheers,
Marie
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DECOMPOSING ERREYGERS CONCENTRATION INDEX - STATA
Next Topic: I need help constructing a variable in Stata
Goto Forum:
  


Current Time: Sun Apr 28 18:29:48 Coordinated Universal Time 2024