The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Bangladesh » Age at first birth
Re: Age at first birth [message #12956 is a reply to message #12955] Mon, 21 August 2017 15:54 Go to previous message
kbietsch_avenir is currently offline  kbietsch_avenir
Messages: 2
Registered: August 2017
Member
I believe I figured it out (at least was able to replicate stat compiler. I found a similar thread in the weighting section. Here is my code in case anyone has the same question in the future:

*******************************************************
clear all
use "C:\Users\KBietsch\Files\DHS Data\Bangladesh\BDIR71FL.DTA", clear
keep if v013==2
keep v005 awfactt v201 v211 v011 v106


gen agefb= (v211-v011)/12
gen fbu18 = 1 if agefb<18
replace fbu18=0 if agefb>=18


* brute force
gen numerator=fbu18*(v005/1000000)
gen denominator1=v005/1000000
gen denominator2=(v005/1000000)*(awfactt/100)

collapse (sum) numerator denominator*

gen mean1=numerator/denominator1
gen mean2=numerator/denominator2

list, table clean


********** Education **********
clear all
use "C:\Users\KBietsch\Files\DHS Data\Bangladesh\BDIR71FL.DTA", clear
keep if v013==2
keep v005 awfactt v201 v211 v011 v106 awfacte


gen agefb= (v211-v011)/12
gen fbu18 = 1 if agefb<18
replace fbu18=0 if agefb>=18

* brute force
gen numerator=fbu18*(v005/1000000)
gen denominator1=v005/1000000
gen denominator2=(v005/1000000)*(awfacte/100)

collapse (sum) numerator denominator*, by(v106)

gen mean1=numerator/denominator1
gen mean2=numerator/denominator2

list, table clean

********** Wealth **********
clear all
use "C:\Users\KBietsch\Files\DHS Data\Bangladesh\BDIR71FL.DTA", clear
keep if v013==2
keep v005 awfactt v201 v211 v011 v106 awfactw v190


gen agefb= (v211-v011)/12
gen fbu18 = 1 if agefb<18
replace fbu18=0 if agefb>=18


* brute force
gen numerator=fbu18*(v005/1000000)
gen denominator1=v005/1000000
gen denominator2=(v005/1000000)*(awfactw/100)

collapse (sum) numerator denominator*, by(v190)

gen mean1=numerator/denominator1
gen mean2=numerator/denominator2

list, table clean
 
Read Message
Read Message
Previous Topic: Reproduction of marriage data in report
Next Topic: Selecting children who "Finished primary school"
Goto Forum:
  


Current Time: Thu Dec 12 00:03:50 Coordinated Universal Time 2024