The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Fertility » compute key figures
compute key figures [message #20111] Sat, 26 September 2020 03:38 Go to next message
kepiluna2 is currently offline  kepiluna2
Messages: 1
Registered: September 2020
Dear DHS-Team,

for my paper, I want to compute some key figures in fertility, like ASFR, parity, PPR and CFR. I use the kenian Data from 1989 - 2014. I´ve matched all KEIR to a general file and classified the women into birthcohorts. While I wanted to compute the age of the women at the particular birth (b3$01 - V011, b3$02 - V011, and so on), I saw that the order of birth is reverse. For example the Variable B3$01 is not the first, but the last birth of the woman. So the age of the woman decreases from birth to birth.
Please tell me how I can reverse the order of the birth or let me know if there is an other way to calculate the age of woman at the time of the particular birth.

Thank you very much!

[Updated on: Sun, 27 September 2020 07:53] by Moderator

Report message to a moderator

Re: compute key figures [message #20135 is a reply to message #20111] Mon, 28 September 2020 13:08 Go to previous messageGo to next message
Shireen-DHS is currently offline  Shireen-DHS
Messages: 29
Registered: August 2020
Location: USA

If you are trying to compute mother's age at birth (in BR or KR file) you can use the following Stata code:

* mother's age at birth (years): <20, 20-29, 30-39, 40-49
gen months_age=b3-v011
gen mo_age_at_birth=1 if months_age<20*12
replace mo_age_at_birth=2 if months_age>=20*12 & months_age<30*12
replace mo_age_at_birth=3 if months_age>=30*12 & months_age<40*12
replace mo_age_at_birth=4 if months_age>=40*12 & months_age<50*12
drop months_age

If you are looking to compute any DHS indicator listed in the Guide to DHS Statistics: x.htm#t=Guide_to_DHS_Statistics_DHS-7.htm

Then please check our code library site on GitHub (both Stata and SPSS code is available). Please read the readme file before attempting to run any code.

Thank you.

Shireen Assaf
The DHS Program
Re: compute key figures [message #20298 is a reply to message #20111] Tue, 20 October 2020 17:52 Go to previous message
schoumaker is currently offline  schoumaker
Messages: 51
Registered: May 2013
Location: Belgium
Senior Member
You can try this. There may be a more straightforard way, but this should work to compute age at birth for first birth (agebirth_1), second birth (ageirth_2) etc.


local listbirths 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20

forval rank=1/20 {
gene agebirth_`rank'=.
foreach birth of local listbirths {
replace agebirth_`rank'=(b3_`birth'-v011)/12 if bord_`birth'==`rank'

Bruno Schoumaker
Centre for Demographic Research
Université catholique de Louvain
Previous Topic: STATE LEVEL DATA
Goto Forum:

Current Time: Thu Oct 22 04:48:01 Eastern Daylight Time 2020