The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » General » MERGING IR AND HR FILE ((Problem with STATA compilation))
Re: MERGING IR AND HR FILE [message #29008 is a reply to message #28965] Wed, 10 April 2024 09:02 Go to previous messageGo to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 720
Registered: April 2022
Senior Member
Following is a response from DHS staff member, Tom Pullum:

You may not realize that the records in the HR file are VERY wide. They include data for everyone in the household, all on the same record. I suspect that what you really want from the HR file is the information that is specifically about the household, but not about the individual members. If you include a line "drop *_*" then you will drop all the subscripted variables in the HR file, that is, those that refer to individuals.

Also you may not realize that the IR file already includes many household-level variables, often with different names. For example, hv270 in the household file is copied into the IR file as v190.

You may want to merge with the PR file, which has one record for each person in the household, rather than the HR file,

I will paste below Stata lines to merge the IR and HR files. The main difference from what you did is the "drop" line in the preparation of the HR file. This works for me and is fast.

* Specify a workspace

cd e:\DHS\DHS_data\scratch

 

* Prepare the HR file; keep only the household-level variables

use "...IAHR7EFL.DTA", clear

drop *_*

gen cluster=hv001

gen hh=hv002

save HRtemp.dta, replace

 

use "...IAIR7EFL.DTA", clear

gen cluster=v001

gen hh=v002

 

merge m:1 cluster hh using HRtemp.dta

 

* Some households have no women in the IR file; drop them

tab _merge

keep if _merge==3

drop _merge 
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Regional variable v024
Next Topic: Agricultural Land ownership: Treatment of Zero values
Goto Forum:
  


Current Time: Tue May 28 09:35:47 Coordinated Universal Time 2024