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
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: 3143
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

 
Read Message
Read Message
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: Tue Aug 20 02:20:21 Coordinated Universal Time 2024