The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging KR with PR (Merging Nigeria 2018 KR(master) with PR(using))
Re: Merging KR with PR [message #25451 is a reply to message #25450] Fri, 21 October 2022 11:30 Go to previous message
kehinde.atoloye@gmail.com is currently offline  kehinde.atoloye@gmail.com
Messages: 3
Registered: October 2022
Member
Thank you. It worked but I had to change the last keep line from keep if _merge==5 & hml32<. to keep if hw1<.. I do not understand why the former drops all observations of hml32. Thanks.


Afterthought: I observed that it also keeps the hml32 observations if I use keep if hml32<. instead of keep if _merge==5 & hml32<.

It will be interesting to know what the condition _merge==5 does. Thanks a million.

* Specify workspace
cd e:\DHS\DHS_data\scratch

* Nigeria 2018
* Combine hml variables in the PR file with the ml variables in the KR file

use "NGPR7BFL.DTA", clear 
keep if hc1<.
rename hv001 cluster
rename hv002 hh
rename hvidx line
keep cluster hh line hml32
sort cluster hh line
save NGPRtemp.dta, replace

use "NGKR7BFL.DTA", clear 
keep if b16>0 & b16<.
rename v001 cluster
rename v002 hh
rename b16 line
keep cluster hh line v0* ml* hw*
sort cluster hh line
merge cluster hh line using NGPRtemp.dta

tab hml32 _merge,m

// keep if _merge==3 & hml32<.

keep if hw1<.
drop _merge

tab hml32

tab hw1 hml32

[Updated on: Mon, 24 October 2022 07:52] by Moderator

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: Merging Male with Birth data?
Next Topic: Merging Datasets PDHS
Goto Forum:
  


Current Time: Fri Apr 26 18:01:17 Coordinated Universal Time 2024