The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use in Stata » I need help constructing a variable in Stata
I need help constructing a variable in Stata [message #74] Wed, 20 February 2013 11:54 Go to next message
DHS user is currently offline  DHS user
Messages: 111
Registered: February 2013
Senior Member
I am using Stata, and would like to know how to construct the variable "" Age of respondent at second birth".
Re: I need help constructing a variable in Stata [message #75 is a reply to message #74] Wed, 20 February 2013 11:56 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3013
Registered: February 2013
Senior Member
Here is a response from one of our STATA experts Tom Pullum that should answer your question.

Go to the IR (women's) file, GHIR4BDT.DTA.  Use the following variables:

The woman's cmc (century month code) of birth is v011
The child's cmc of birth is b3
The birth order is given by bord.  For the second birth, the cmc of birth is b3_02

Define a new variable, which I will call mageb02, the mother's age at the birth of the second child, with

gen mageb02=int((b3_02-v011)/12)

In Stata, this will be coded "missing" (.) if there was no second birth. The int command gives the integer part of any number.

The only possible issue arises when the mother and child are both born in the same calendar month.  My formula would say that if, for example, the mother was born in March 1980 and the child was born in March 2000, then the mother was 20 years old at the time of the birth.  However, it is possible that the mother was born on March 20, say, and the child was born on March 10, so that the mother was actually only 19 at the time of the birth (and turned 20 ten days after the birth).  This is the sort of issue that gives demographers gray hair.  The usual way to resolve it would be to say that all births, for the mother and her children, occur on the same day of the month (the 15th, for example). Then the child would have been born right on the mother's 20th birthday and the formula would be ok.

I suggest that if you are comparing with something given in the final report, you try to replicate with this formula.  You will need to use weights (v005) for any means or tabulations, etc.

I hope this helps.

Bridgette-DHS

[Updated on: Mon, 18 March 2013 08:18]

Report message to a moderator

Re: I need help constructing a variable in Stata [message #13066 is a reply to message #75] Thu, 14 September 2017 10:50 Go to previous messageGo to next message
gafap is currently offline  gafap
Messages: 3
Registered: April 2017
Member
Dear Bridgette,

Maybe I got confused, but in your answer you say that "For the second birth, the cmc of birth is b3_02". As far as I can understand, b3_02 is the time of birth for the second to last birth, but not to the second birth for the mother (where first-child is the first one and so on). Furthermore, see explanation here
https://userforum.dhsprogram.com/index.php?t=tree&goto=1 3065&#page_top

Which one is correct?

And if this is correct, then how do you calculate age at second birth?

thanks!
g

[Updated on: Thu, 14 September 2017 10:52]

Report message to a moderator

Re: I need help constructing a variable in Stata [message #13091 is a reply to message #13066] Mon, 18 September 2017 10:05 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3013
Registered: February 2013
Senior Member
Here is another response from DHS Stata Expert, Tom Pullum:


The following Stata lines should accomplish what you want, with the births re-sequenced by birth order rather than by recency.

quietly summarize v201
scalar max_ceb=r(max)

keep v011 b3* bord*
rename b*_0* b*_*

* bord_1 is the birth order of the most recent birth
* the first birth will be the one for which bord_1=1 or bord_2=1 or bord3=1, etc
* the second birth will be the one for which bord_1=2 or bord_2=2 or bord3=2, etc

local lj=1
quietly while `lj'<=max_ceb {
gen b3ordered_`lj'=.

  local li=1
  while `li'<=max_ceb {
  replace b3ordered_`lj'=b3_`li' if bord_`li'==`lj'
  local li=`li'+1 
  }

local lj=`lj'+1
}

summarize b3_*
summarize b3ordered_*
Previous Topic: Calculating median age at first sex and percentage of respondents with sex before the age of 15
Next Topic: Opening DHS data on STATA 13
Goto Forum:
  


Current Time: Mon Mar 18 22:39:07 Coordinated Universal Time 2024