The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merge PR and KR in wave 3, b16 does not exist
Merge PR and KR in wave 3, b16 does not exist [message #14951] Sat, 19 May 2018 12:59 Go to next message
nibiti is currently offline  nibiti
Messages: 20
Registered: April 2018
Location: Göttingen
Member
Hi all,

I am trying to merge PR with KR datasets for Sub-Saharan Africa, using PR as the base file. I have encountered a problem that many seem to have faced in this forum. My Stata tells me that my "variables hv001 hv002 and hvidx do not uniquely identify the observations in the using data".

Now, I have tried to find an answer in other forum threads (like this one: https://userforum.dhsprogram.com/index.php?t=msg&goto=28 46&) and the suggested answer seems to use b16 as identifier instead.

However, I face two problems:

1. b16 seems to not have been part of wave 3 and is not included in any of the wave 3 datasets. Is there a way in which I can still merge PR and KR datasets for wave 3? What identifier should be used instead?

Edit: I found my own answer here: https://userforum.dhsprogram.com/index.php?t=msg&th=1900 &goto=10942&S=Google where it says that wave 3 is indeed not available.


2. For wave 4 to 7 I still receive the same error message again. That my variables (hv001/v001, hv002/v002, hvidx/b16) do not uniquely identify my observations.

Edit: I also tried dropping b16 for values of 0 or 99, but the error message remains.

Many thanks in advance!

Best regards
Timo

[Updated on: Sat, 19 May 2018 13:37]

Report message to a moderator

Re: Merge PR and KR in wave 3, b16 does not exist [message #14958 is a reply to message #14951] Mon, 21 May 2018 12:58 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3215
Registered: February 2013
Senior Member

Following is a response from Senior DHS Stata Specialist, Tom Pullum:

For the early surveys that do not include b16, there is no foolproof way to merge the PR and KR files. You can come close, using the sex and age of the child, but this will not always work, because there are genuine matches in which the age of the child is different in the two files.

Users may be able to suggest something but within DHS we have not found a reliable way to do this.
Re: Merge PR and KR in wave 3, b16 does not exist [message #14961 is a reply to message #14958] Tue, 22 May 2018 08:28 Go to previous messageGo to next message
nibiti is currently offline  nibiti
Messages: 20
Registered: April 2018
Location: Göttingen
Member
Hi Tom,

thanks for your reply. I have dropped the KR wave 3 data now.


But do you also have an answer for my second question? hv001/v001, hv002/v002 and hvidx/b16 do not uniquely identify the data in wave 4 and in wave 6, independent of the country (I am using all Sub-Saharan African countries).

I am using the exact same code for wave 5 and there the merge works fine. But for wave 4 and wave 6 it does not seem to work. My code broadly looks like this:

In KR file:
rename v001 hv001
rename v002 hv002
rename b16 hvidx

In PR file:
sort hv001 hv002 hvidx
merge 1:1 hv001 hv002 hvidx using "KR.dta"

This leads to the following error message:

"variables hv001 hv002 hvidx do not uniquely
identify observations in the using data
r(459);"


Any ideas?

Best
Timo
Re: Merge PR and KR in wave 3, b16 does not exist [message #15192 is a reply to message #14961] Thu, 14 June 2018 11:06 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3215
Registered: February 2013
Senior Member
Following is a response from DHS Technical Specialist, Shireen Assaf:

The following code should work for a KR PR merge. I'm using the Rwanda most recent survey as an example.


use RWKR70FL.DTA, clear             
               
               rename v001 hv001
               rename v002 hv002
               rename b16  hvidx
               
               * dropping those that are not in the household so we can merge with PR file
               drop if hvidx==0 | hvidx==.

               sort hv001 hv002 hvidx
               
               save temp.dta, replace
               
               use RWPR70FL.DTA, clear             

               sort hv001 hv002 hvidx
               merge 1:1 hv001 hv002 hvidx using temp.dta
               
               erase temp.dta
Re: Merge PR and KR in wave 3, b16 does not exist [message #15379 is a reply to message #14951] Sun, 08 July 2018 23:16 Go to previous messageGo to next message
kingx025 is currently offline  kingx025
Messages: 95
Registered: August 2016
Location: Minneapolis. Minnesota
Senior Member
I'm not sure what data you need to secure by merging the PR and KR observations. If you need some background characteristics about the households, such as type of toilet facility, source of drinking water, etc. as well as the child data, an alternative approach may be to go to IPUMS-DHS (www.idhsdata.org), choose children as your unit of analysis (data from the KR file), and select additional variables relating to the mother's or household characteristics. We have merged the household file (HR) to the mother's (IR) files, and merged both to children's records (and birth records). Thus, if you create a customized dataset using IPUMS-DHS and children as the unit of analysis, you can add any characteristics related to the child's mother (including some not included in the original KR files, such as experience of domestic violence) and summary variables about the mother's household, such as type of toilet facility, source of water, wealth index, housing characteristics, agricultural and non-agricultural possessions, anti-malarial measures, nutritional indicators (such as iodized salt), and summary geography indicators.

The linking problems referred to in other messages in this thread did not affect our linking households to women (HR to IR) and linking women/mothers to children (IR to KR), so the approach described above may be a more general as well as a less labor-intensive solution.

Miriam King


Dr. Miriam King
IPUMS-DHS Project Manager (www.idhsdata.org)
Re: Merge PR and KR in wave 3, b16 does not exist [message #18429 is a reply to message #15379] Thu, 28 November 2019 07:27 Go to previous messageGo to next message
zelalem is currently offline  zelalem
Messages: 7
Registered: November 2019
Member
hi Dr. Miriam

I am analysing Ethiopian dhs 2016 data on prevalence of anemia and associated factors in children aged 6-59 months. In this case I have faced a mismatch b/n the report and the data set ETKR71FL, but it matches when I used ETPR71FL. Now what I have faced is that after merging PR &KR files, the result does not match with the report. type of merge I have used is 1:m in other cases it shows an error syntax. The reason that I want to merge pr with kr is; to get the associated factors for anemia...¡.e maternal facors, child related factors, ....so on

If any better directions please foreward.
Re: Merge PR and KR [message #21769 is a reply to message #14951] Wed, 16 December 2020 06:34 Go to previous message
ask_ans_sri is currently offline  ask_ans_sri
Messages: 2
Registered: June 2018
Location: DELHI
Member
I have used the following syntax for merging PR and KR files on NFHS-4

use kr.dta

rename (v001 v002 b16)(hv001 hv002 hvidx)

drop if hvidx==0 | hvidx==.

save kr.dta

use pr.dta

sort hv001 hv002 hvidx

merge m:m hv001 hv002 hvidx using kr.dta

The results are as follows



Result # of obs.
-----------------------------------------
not matched 2,624,197
from master 2,624,194 (_merge==1)
from using 3 (_merge==2)

matched 244,855 (_merge==3)


I am working on KR file. I have estimated stunting varibale from KR file and need some variables from PR file.
The stunting estimate is matching with the reported figure.

. ta child_stunt [aw=wt]

child_stunt Freq. Percent Cum.

0 143,158.22 61.59 61.59
1 37,867.5617 16.29 77.88
2 51,414.222 22.12 100.00

Total 232,440 100.00

in child_stunt 1 is below -300.
But I am having issue of tallying the frequencies. The frequency I am getting is not matching with the report (page 337).

Please do let me know if I am doing anything wrong.
Thanks in advance.
Previous Topic: Survey identifiers
Next Topic: Merging household and women's individual data Myanmar 2015-2016
Goto Forum:
  


Current Time: Mon Dec 30 13:28:35 Coordinated Universal Time 2024