Merging data [message #10190] |
Thu, 07 July 2016 06:18 |
Lukresha
Messages: 14 Registered: July 2016
|
Member |
|
|
I am working with data from KDHS and most of the variables I would like to use are in the PR file and MR file. I have seen that a previous question was already asked on the forum but I would like to know whether there is a way I can merge the data such that I do not lose part of my age(hv105)values.
Using advice from the previous posts, this is how I carried out my merging:
use "\\smbhome.uscs.susx.ac.uk\ln201\Desktop\KDHS\KEMR70FL.DTA", clear
rename mv001 hv001
rename mv002 hv002
rename mv003 hvidx
save "\\smbhome.uscs.susx.ac.uk\ln201\Desktop\KDHS\KEMR70FL.DTA", replace
file \\smbhome.uscs.susx.ac.uk\ln201\Desktop\KDHS\KEMR70FL.DTA saved
use "\\smbhome.uscs.susx.ac.uk\ln201\Desktop\KDHS\KEPR70FL.DTA", clear
sort hv001 hv002 hvidx
merge hv001 hv002 hvidx using MRtemp.dta
tab _merge
_merge | Freq. Percent Cum.
------------+-----------------------------------
1 | 141,021 91.67 91.67
3 | 12,819 8.33 100.00
------------+-----------------------------------
Total | 153,840 100.00
The output I get on age of household members before using keep if _merge==3 is:
sum hv105
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------- -----------
hv105 | 153,822 22.67255 19.12394 0 95
But after keep if _merge==3 is:
sum hv105
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------- -----------
hv105 | 12,819 30.07645 10.90915 15 54
I am kindly inquiring if there is a way I can merge such that hv105 will have values beginning from 0-15 as that's the desired age group I would like to focus on.
Thank you.
|
|
|