The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Weighting data » Residing in same household in KR file (Create vaiable for residing in same household)
Re: Residing in same household in KR file [message #31188 is a reply to message #28758] Mon, 21 July 2025 02:31 Go to previous message
RashadUpton is currently offline  RashadUpton
Messages: 1
Registered: July 2025
Member
Step 1: Create a unique household identifier
gen hh_id = v001*1000 + v002
Step 2: Calculate the number of people in each household
bysort hh_id: gen hh_count = _N
Step 3: Create binary variable "Resides with household"
gen same_household = hh_count > 1

Where Geometry Dash Scratch:
v001 is the cluster code
v002 is the household number
hh_id is the unique code for each household
_N in bysort will count the number of observations in each hh_id
same_household will be:
1: if the household has >1 person (has someone living with the household)
0: if the household has only 1 person (no one living with the household)

[Updated on: Mon, 21 July 2025 20:04]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: Sampling
Goto Forum:
  


Current Time: Wed Aug 20 06:14:58 Coordinated Universal Time 2025