The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging child's malaria results from HH member recode dataset with other child data in Child recode
Re: Merging child's malaria results from HH member recode dataset with other child data in Child recode [message #3061 is a reply to message #3010] Thu, 09 October 2014 15:55 Go to previous message
kate2
Messages: 15
Registered: May 2014
Member
Hi Trevor,

Thanks again for offering to help.

I have moved over to Stata.

The below is cut and paste from my log file. This has helped me understand the difference in the case numbers. From the below I can see that there are 8648 cases in the KR file and that 7914 of these are matched in the HH member file, the difference is those in the KR file that are not matched in the HH file. So I can see now that its my choice of whether to retain all 8648 or only those 7914 that are matched. I think for the merge I did in SPSS previously I must have used an command which automatically only retained those cases that were matched.

Anyhow - I now am clear on this...and just need to work out what I want to keep!

Thanks a lot
Kate

------------------------------------------------------------ ------------------------------------------------------------ ------------------------
name: <unnamed>
log: /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/Merging data.smcl
log type: smcl
opened on: 3 Oct 2014, 10:19:05

. use " /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZPR6AF L.DTA "

. rename hv001 v001

. rename hv002 v002

. rename hvidx mergeid

. sort v001 v002 mergeid

. gen in_PR=1

. save " /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZPR6AF L_renamed_sorted.dta "
file /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZPR6AF L_renamed_sorted.dta saved

. clear

. use " /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZKR6AF L.DTA "

. rename b16 mergeid

. sort v001 v002 mergeid

. gen in_KR=1

. save " /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZKR6AF L_renamed_sorted.dta "
file /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZKR6AF L_renamed_sorted.dta saved

. merge m:1 v001 v002 mergeid using " /Users/admin/Dropbox/MPH/Dissertation/Datasets/Stata/TZPR6AF L_renamed_sorted.dta "

Result # of obs.
-----------------------------------------
not matched 46,840
from master 734 (_merge==1)
from using 46,106 (_merge==2)

matched 7,914 (_merge==3)
-----------------------------------------

. tab1 _merge in_KR in_PR

-> tabulation of _merge

_merge | Freq. Percent Cum.
------------------------+-----------------------------------
master only (1) | 734 1.34 1.34
using only (2) | 46,106 84.21 85.55
matched (3) | 7,914 14.45 100.00
------------------------+-----------------------------------
Total | 54,754 100.00

-> tabulation of in_KR

in_KR | Freq. Percent Cum.
------------+-----------------------------------
1 | 8,648 100.00 100.00
------------+-----------------------------------
Total | 8,648 100.00

-> tabulation of in_PR

in_PR | Freq. Percent Cum.
------------+-----------------------------------
1 | 54,020 100.00 100.00
------------+-----------------------------------
Total | 54,020 100.00

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merging SPA and DHS data
Next Topic: v001 v002 v003 doesnot uniquely identify observation
Goto Forum:
  


Current Time: Tue Dec 3 08:57:46 Coordinated Universal Time 2024