Combining KR and PR files [message #10712] |
Mon, 05 September 2016 09:15 |
waltine
Messages: 21 Registered: March 2013 Location: South Africa
|
Member |
|
|
Dear All,
I am trying to merge the KR and BR files but I keep getting this error message even after following steps in previous "Merge threads".
Error: variables hv001 hv002 hvidx do not uniquely identify observations in the using data.
Syntax:
use "E:\NDHS 2013\ngkr6adt\NGKR6AFL.DTA", clear
. ren v001 hv001
. ren v002 hv002
. ren b16 hvidx
. sort hv001 hv002 hvidx
. save "C:\Users\Somefun\Desktop\Working Papers\Child Health Outcomes\KR.dta", replace
file C:\Users\Somefun\Desktop\Working Papers\Child Health Outcomes\KR.dta saved
. use "E:\NDHS 2013\ngpr6adt\NGPR6AFL.DTA", clear
. sort hv001 hv002 hvidx
. merge 1:1 hv001 hv002 hvidx using "C:\Users\Somefun\Desktop\Working Papers\Child Health Outcomes\KR.dta"
variables hv001 hv002 hvidx do not uniquely identify observations in the using data
r(459);
Thank you.
waltine
|
|
|
|
Re: Combining KR and PR files [message #10719 is a reply to message #10718] |
Tue, 06 September 2016 09:37 |
Bridgette-DHS
Messages: 3214 Registered: February 2013
|
Senior Member |
|
|
Following is a response from Senior DHS Stata Specialist, Tom Pullum:
After your first line ("use...., clear") you need to insert this line: "drop if b16==0 | b16==." . The KR and BR files include children who have died or who are not living with the mother, and for them b16 will be "0" or "." . There may be more than one such child with a specific combination of v001 and v002. Otherwise you are ok.
|
|
|