The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Weighting data » Ratio of girls to boys in a family
Ratio of girls to boys in a family [message #16559] Fri, 25 January 2019 23:27 Go to next message
sumonrupop is currently offline  sumonrupop
Messages: 23
Registered: August 2015
Location: Rajshahi
Member

Dear all,
Can anyone help me to calculate the ratio of girls to boys in a family? I found this should be calculated by using b2_01, b2_04, and b2_05 variables in IR file, but facing a problem when I tried to count male and female child.


Thanks in advance.

Sumon


Md. Nuruzzaman Khan
Re: Ratio of girls to boys in a family [message #16571 is a reply to message #16559] Tue, 29 January 2019 08:12 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member
Following is a response from Senior DHS Stata Specialist, Tom Pullum:

There are two ways to do this. The easy way is with the first two lines below. The second way is to loop through the b variables, as you were trying to do. The last three lines will confirm that you get the same results with both methods.

gen boys1=v202+v204+v206
gen girls1=v203+v205+v207

ren b*_0* b*_*
local li=1
while `li'<=20 {
gen boy_`li'=1 if b4_`li'==1
gen girl_`li'=1 if b4_`li'==2
local li=`li'+1
}

egen boys2=rowtotal(boy_*)
egen girls2=rowtotal(girl_*)

correlate boys*
correlate girls*
summarize boys* girls*

[Updated on: Tue, 29 January 2019 08:18]

Report message to a moderator

Previous Topic: Weighting between DHS and non DHS surveys
Next Topic: Using weights for merged PR&IR file NFHS-4(2015-16), India
Goto Forum:
  


Current Time: Fri Mar 29 02:13:43 Coordinated Universal Time 2024