The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Nigeria » chap 9 reproductive health (generate age and period )
chap 9 reproductive health [message #25369] Wed, 12 October 2022 16:12 Go to next message
anum.ali is currently offline  anum.ali
Messages: 6
Registered: September 2022
Member
Hello

I am trying to generate different indicators for chap 9 for nigeria 2018 to produce different tables the problem is I am trying to generate age through this coding but somehow my software stata keeps on getting stuck and not letting me work please help how else can I produce age variable

choose reference period, last 2 years or last 5 years
*gen period = 24
gen period = 60

if file=="IR" {
gen age = v008 - b3_01

* to check if survey has b19, which should be used instead to compute age.
scalar b19_included=1
capture confirm numeric variable b19_01, exact
if _rc>0 {
* b19 is not present
scalar b19_included=0
}
if _rc==0 {
* b19 is present; check for values
summarize b19_01
if r(sd)==0 | r(sd)==. {
scalar b19_included=0
}
}

if b19_included==1 {
drop age
gen age=b19_01
}
Re: chap 9 reproductive health [message #25401 is a reply to message #25369] Fri, 14 October 2022 16:30 Go to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 657
Registered: April 2022
Senior Member
Following is a response from DHS staff member Tom Pullum:

There are various ways to do this. Here is one that has minimal modification of your code:

scalar b19_included=1

capture confirm numeric variable b19_01, exact
if _rc>0 {
* b19 is not present
gen age = v008 - b3_01
scalar b19_included=0
}

if _rc==0 {
* b19 is present
gen age=b19_01

* Check values of b19
summarize b19_01
if r(sd)==0 | r(sd)==. {
replace age = v008 - b3_01
scalar b19_included=0
}

Previous Topic: sanitation service
Next Topic: chap 11(Nutrition indicator)
Goto Forum:
  


Current Time: Thu Mar 28 08:31:14 Coordinated Universal Time 2024