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 #28703 is a reply to message #28696] Tue, 27 February 2024 11:30 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

The following Stata lines work for this merge (at least for me). I only include a few variables--you will want to revise to include more. You could put a line before "save MRtemp* such as "rename mv* v*" so the mv variables for men will be renamed as v variables. I have assumed that you are using the most recent CI survey. Hope this does what you want.

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

use "...CIIR81FL.DTA", clear 
keep v0*
gen in_IR=1
tab1 in*
gen cluster=v001
gen hh=v002
gen line=v003
save IRtemp.dta, replace

use "...CIMR81FL.DTA", clear 
keep mv0*
gen in_MR=1
tab1 in*
gen cluster=mv001
gen hh=mv002
gen line=mv003
save MRtemp.dta, replace

use "...CIPR81FL.DTA", clear 
keep hv0* hvidx
gen in_PR=1
tab1 in*
gen cluster=hv001
gen hh=hv002
gen line=hvidx

* 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

 
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: Mon Nov 25 00:11:22 Coordinated Universal Time 2024