The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » merge IR MR AND PR (Hypertension in Côte d'Ivoire)
Re: merge IR MR AND PR [message #28989 is a reply to message #28703] Mon, 08 April 2024 15:56 Go to previous messageGo to previous message
tanvirpmc04 is currently offline  tanvirpmc04
Messages: 5
Registered: April 2024
Location: Bangladesh
Member
Hi
I am interested in merging IR and MR with PR, append them, then creating a common variable BMI from variables ha2, ha3, hb2 and hb3. I have used the following codes:

clear
set maxvar 100000

use " C:\Users\Hp\Desktop\datasets\nepal_dhs\NPIR82DT\NPIR82FL.DTA "
gen sex = 2
gen in_IR=1
tab1 in*
gen cluster=v001
gen hh=v002
gen line=v003
gen id=CASEID
sort cluster hh line id
save IRtemp.dta, replace

use " C:\Users\Hp\Desktop\datasets\nepal_dhs\NPMR82DT\NPMR82FL.DTA ", clear
gen sex = 1
gen in_MR=1
tab1 in*
gen cluster=mv001
gen hh=mv002
gen line=mv003
gen id=MCASEID
sort cluster hh line id
save MRtemp.dta, replace

use " C:\Users\Hp\Desktop\datasets\nepal_dhs\NPPR82DT\NPPR82FL.DTA "
gen in_PR=1
tab1 in*
gen cluster=hv001
gen hh=hv002
gen line=hvidx
gen id=HHID
sort cluster hh line id

* Merge PR with IR
merge 1:1 cluster hh line using IRtemp.dta
rename _merge merge_PR_IR

* Merge with MR
merge 1:1 cluster hh line using MRtemp.dta
rename _merge merge_PR_MR
save IRMRPR.dta, replace

keep if merge_PR_IR==3 | merge_PR_MR==3
tab in_IR in_MR,m

However, if i then use: tab hb2 or hb3, it returns no observation. Can you please help me to identify the error?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merging children in IR with children in PR
Next Topic: IR and NR files
Goto Forum:
  


Current Time: Thu Nov 28 16:16:57 Coordinated Universal Time 2024