The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Are the merging commands and results correct (Verifying the correctness of IR and PR Files merging command)
Are the merging commands and results correct [message #18794] Sat, 22 February 2020 16:19 Go to next message
okunloladavid is currently offline  okunloladavid
Messages: 4
Registered: February 2020
Member
Dear all,

Please I need your help in checking if the commands below are valid.

I am merging the IR file (in 2018 the Nigerian Demographic and Health Survey). This is because, I wanted the socio-demographics, economic characteristics and nutritional status of women (BMI) in the IR file appearing in the PR file since the PR file contains dejure and defacto respondents and should be linkable to the IR. I intend examining the relationship between maternal nutritional status and U5 children's nutritional statust (wasting, underweight etc). among others.

These are my commands:

//Preparing PR recode for merging
***Preparing women recode for merging
cd " C:\Users\USER\Documents\NG_2018_DHS_11292019_1323_116593\NGP R7ADT "
use "NGPR7AFL.DTA",clear
rename hv001 v001
rename hv002 v002
sort v001 v002 hvidx
duplicates list v001 v002 hvidx
save "C:\Users\USER\Desktop\Papers, Journals, project\Lawal\New project\PR.dta", replace


//Preparing IR recode for merging
cd " C:\Users\USER\Documents\NG_2018_DHS_11292019_1323_116593\NGI R7ADT "
use caseid v000 v001 v002 v003 v004 v131 v130 v717 v445 v106 v013 v190 v717 v025 v130 v131 v024 using "NGIR7AFL.DTA", clear
rename v003 hvidx
sort v001 v002 hvidx
duplicates list v001 v002 hvidx
save "C:\Users\USER\Desktop\Papers, Journals, project\Lawal\New project\Data 2.dta", replace

//merging IR to PR file
cd "C:\Users\USER\Desktop\Papers, Journals, project\Lawal\New project"
use "PR.dta",clear
merge 1:1 v001 v002 hvidx using "Data 2.dta"

//keeping cases (matched and unmatched)
keep if _merge==1 |_merge==3



I noticed that total observations for variables are so different.

I will be glad to hear from anyone. Thank you very much.

Re: Are the merging commands and results correct [message #18947 is a reply to message #18794] Tue, 24 March 2020 14:18 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3016
Registered: February 2013
Senior Member

Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

I recommend that when you change the names of the matching variables, you consistently use EITHER the PR variable names OR the IR variable names. For example, rename hv001 v001; rename hv002 v002; rename hvidx v003. Then sort both files on v001 v002 v003. The way you did it will work but it's not as systematic.

I think the merge has worked ok. My rule of thumb is that about a quarter of the people in the PR file will be women age 15-49. That is, the cases with _merge=1 will be about 3 times as large as the cases with _merge=3. If that's what you got, you are ok.

You could consider reducing the PR file to women age 15-49, right after the "use ...PR...". This will give you both the de fact and de jure residents.


Re: Are the merging commands and results correct [message #22595 is a reply to message #18947] Thu, 08 April 2021 17:22 Go to previous message
okunloladavid is currently offline  okunloladavid
Messages: 4
Registered: February 2020
Member
Thank you very much for your response
Previous Topic: INDIA - NFHS-4 - PR AND CR
Next Topic: Merging variables from original DHS with IPUMS DHS
Goto Forum:
  


Current Time: Thu Mar 28 05:35:42 Coordinated Universal Time 2024