The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Malaria Indicator Survey: Malaria outcomes and women's characteristics
Re: Malaria Indicator Survey: Malaria outcomes and women's characteristics [message #8930 is a reply to message #8778] Fri, 15 January 2016 10:49 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3214
Registered: February 2013
Senior Member
Following is a response from Senior DHS Stata Specialist, Tom Pullum:

The three variables you want to combine are hml32, v130, and s507. The PR file includes everyone, adults and children; it includes hml32 but that variable is only for children under 5. The IR file has only women 15-49 and contains v130 and s507. The KR file has a record for each child under five, but the information for the mother is attached to each child's record. Therefore v130 and s507 are in the KR file, as well as the IR file. Therefore, to construct a file that includes hml32, v130, and s507, you only need to merge the PR and KR files. You do not need to include the IR file in this process.

When you do this merge you will be limited to children under five whose mother was in the household. That is, there are some children in the PR file who will not be in the KR file because their mother has died or for some other reason is not in the household. In the KR file, b16 is the line number of the child in the PR file. I see that for this survey there are only 56 such children. The final file has 2,022 children in it.

The following lines will do the merge. You must change the paths. If you have questions about it, you should be able to find answers in earlier postings.

use e:\DHS\DHS_data\KR_files\MWKR71FL.dta, clear
gen hv001=v001
gen hv002=v002
gen hvidx=b16
sort hv001 hv002 hvidx
save e:\DHS\DHS_data\scratch\temp.dta, replace

use e:\DHS\DHS_data\PR_files\MWPR71FL.dta, clear
sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using e:\DHS\DHS_data\scratch\temp.dta
tab _merge
keep if _merge==3
drop _merge

tab1 hml32 v130 s507
 
Read Message
Read Message
Read Message
Previous Topic: Duplicates in IR file when merging
Next Topic: Partners variables
Goto Forum:
  


Current Time: Mon Dec 23 15:33:50 Coordinated Universal Time 2024