Home » Data » Merging data files » Merging BR file with PR file for NFHS-4 round(India) (Merging BR and PR)
|
Re: Merging BR file with PR file for NFHS-4 round(India) [message #17839 is a reply to message #17833] |
Sun, 23 June 2019 19:43 |
preshit
Messages: 13 Registered: March 2018 Location: Tucson, AZ, USA
|
Member |
|
|
On follow up to my query, I attempted the code provided by Bridgette-DHS in the link-https:// userforum.dhsprogram.com/index.php?t=msg&th=8202&got o=17795&#msg_17795.
I was able to merge PR and BR file; however, many cases were missing (please see the codes and out put below). Am I missing anything in my merging code? Also, I don't want to loose information on children who are not listed in household or missing in b16. Any help in merging NFHS-4 PR and BR file will be highly appreciated. Thank you.
*BR-file
use IABR74FL.DTA,clear
tab b16,m
tab b16,nolabel //"0"- not listed in household, missing values= 93,251
keep if b16>0 & b16<39 //missing values and children coded "0"- i.e. not listed in household were deleted
keep v001 v002 v003 v005 v024 b*
gen in_BR=1
rename v001 hv001
rename v002 hv002
rename b16 hvidx
rename v003 hv003
rename v024 hv024
sort hv001 hv002 hv003 hvidx hv024
describe, short //1,051,750 observations sort on hv001 hv002 hv003 hvidx hv024
save BR_reduced.dta, replace
clear all
*PR-file
use IAPR74FL.DTA,clear
keep hv001 hv002 hvidx hv0* hv1*
gen in_PR=1
sort hv001 hv002 hv003 hvidx hv024
describe,short //2,869,043 observations sort on hv001 hv002 hv003 hvidx hv024
save PR_reduced.dta, replace
clear all
*merge
use PR_reduced.dta, clear
merge 1:1 hv001 hv002 hv003 hvidx hv024 using BR_reduced.dta
/*
Result # of obs.
-----------------------------------------
not matched 3,008,433
from master 2,412,863 (_merge==1)
from using 595,570 (_merge==2)
matched 456,180 (_merge==3)
-----------------------------------------
*/
[Updated on: Sun, 23 June 2019 19:44] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Fri Dec 20 12:42:27 Coordinated Universal Time 2024
|