The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging Senegal KR files to PR files
Re: Merging Senegal KR files to PR files [message #24150 is a reply to message #24149] Fri, 04 March 2022 07:18 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3043
Registered: February 2013
Senior Member
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

You have made an interesting discovery. It happens that there are two duplicated children in the KR file, specifically those with b16=6 and 7 in the household with v001=43 and v002=14.

Your Stata code was correct. When you get the kind of message you got, with "merge 1:1", you can change to an older and more flexible version of the command, just "merge". I won't go into all the steps I used, but I found that the duplicates were in the KR file, not the PR file, and then ran these lines in the KR file:

sort v001 v002 b16
egen dup=seq() if b16~=0 & b16~=., by(v001 v002 b16)
tab dup,m

You can then list v001 v002 b16 for the cases with dup=2.

If you add two more lines:
drop if dup==2
drop dup
Then you have a file with no duplicates and the 1:1 merge will work ok. I will report this and I hope eventually a corrected file will be issued. Thanks for discovering this issue! The problem was not with your code, but with the data file.
 
Read Message
Read Message
Read Message
Previous Topic: Merging MR to KR
Next Topic: Linking parents to anthropometric Data
Goto Forum:
  


Current Time: Sun Apr 28 20:23:15 Coordinated Universal Time 2024