The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Nigeria » Merging Household member and Individual Recode files for Nigeria 1999
Merging Household member and Individual Recode files for Nigeria 1999 [message #3009] Fri, 03 October 2014 09:20 Go to next message
MBruederle
Messages: 11
Registered: August 2014
Member
Dear DHS team,
I tried to merge household members to individuals (in stata) as follows:
In the household member recode file, I generated new variables
gen v001 = hv001
gen v002 = hv002
gen v003 = hvidx,
and then merged with individual recode file on v001 v002 v003.
Of the 9810 observations in the individual recode file, 2860 were not matched. What could be the reason? Shouldn't all the interviewed women be represented in the household member file?
Many thanks in advance for your help.
Anna BrĂ¼derle

[Updated on: Fri, 03 October 2014 09:23]

Report message to a moderator

Re: Merging Household member and Individual Recode files for Nigeria 1999 [message #3011 is a reply to message #3009] Fri, 03 October 2014 11:11 Go to previous messageGo to next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 787
Registered: January 2013
Senior Member
Hi Anna,

This is a strange case and it took a bit to pinpoint the issue. When I browsed the data I could see the data that were supposed to match but using the commands you used I couldn't get them to match either. If I did a rename of variables rather than generating new variables I got the data to match. Finally I discovered that the gen command with v001 was not creating a variable of the same type, but rather was creating a float type variable. So to solve the problem, you need to set the type of variable when using the gen command for v001 as follows:
gen long v001 = hv001
gen v002 = hv002
gen v003 = hvidx
Then when you merge you should find all cases matching.
Re: Merging Household member and Individual Recode files for Nigeria 1999 [message #3026 is a reply to message #3011] Mon, 06 October 2014 06:44 Go to previous messageGo to next message
MBruederle
Messages: 11
Registered: August 2014
Member
Excellent, now the match worked out.
Thank you very much for the immediate reply.
Anna
Re: Merging Household member and Individual Recode files for Nigeria 1999 [message #3076 is a reply to message #3026] Mon, 13 October 2014 09:15 Go to previous messageGo to next message
kalfikirsisay@gmail.com is currently offline  kalfikirsisay@gmail.com
Messages: 11
Registered: October 2014
Location: NL
Member
Dear MBruederle ,
Still I tried both methods(gen long v001 = hv001,gen v002 = hv002,gen v003 = hvidx)and the rename approach, both turned out not to work and STATA gave me similar results as before"variables v001 v002 v003 do not uniquely identify observations in the using data". What is wrong with my case? your quick elaboration is highly appreciated,
Regards,
Kalkidan Sisay
Re: Merging Household member and Individual Recode files for Nigeria 1999 [message #3079 is a reply to message #3076] Mon, 13 October 2014 10:20 Go to previous messageGo to next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 787
Registered: January 2013
Senior Member
If you include the exact code you are using we can try to debug it for you.
Re: Merging Household member and Individual Recode files for Nigeria 1999 [message #3090 is a reply to message #3076] Mon, 13 October 2014 17:43 Go to previous messageGo to next message
user-rhs is currently offline  user-rhs
Messages: 132
Registered: December 2013
Senior Member
Kalkidan,
Did you try to do a [something]-to-one merge (e.g. merge 1:1 or merge m:1)? If you did, and the using data that you specified as "one" has duplicate IDs, then Stata will tell you that the variables do not uniquely identify the observations. You need to figure out whether it makes sense in your case that the using data should have more than 1 observation with the same ID, and if that is the case, then you should do a [something]-to-many merge (merge 1:m, merge m:m) instead of merge 1:1 or merge m:1.

Re: Merging Household member and Individual Recode files for Nigeria 1999 [message #3118 is a reply to message #3090] Fri, 17 October 2014 08:57 Go to previous message
kalfikirsisay@gmail.com is currently offline  kalfikirsisay@gmail.com
Messages: 11
Registered: October 2014
Location: NL
Member
Dear Sir,
thanks for your elaboration,
Previous Topic: Variables related to country's regions
Next Topic: Migrant Variable
Goto Forum:
  


Current Time: Thu Mar 28 19:39:49 Coordinated Universal Time 2024