MERGING IR MR & PR FILES [message #25775] |
Wed, 07 December 2022 23:32 |
parul_jain
Messages: 5 Registered: June 2020
|
Member |
|
|
Hi I am interested in merging IR MR & PR FILES together for DHS 2015-16 for India. Can you tell me how this could be done in stata?
|
|
|
Re: MERGING IR MR & PR FILES [message #25806 is a reply to message #25775] |
Tue, 13 December 2022 16:27 |
Janet-DHS
Messages: 893 Registered: April 2022
|
Senior Member |
|
|
Following is a response from DHS staff member Tom Pullum:
The following Stata code will do this merge. You will have to change the paths to the workspace and the data files. Note that only 1/6 of the households were selected for the survey of men. (1/2 of the households in 1/3 of the clusters.) As a result there are many fewer men than women. The PR file includes all household members, not just those 15-49 who were selected for the individual surveys of women and men. Note also that in the India surveys, state (or region, hv024), is included in the ID code.
* Specify workspace
cd e:\DHS\DHS_data\scratch
* Save IR, MR, PR files, reduced to the needed variables
use "...IAIR74FL.DTA", clear
keep v0*
save IR.dta, replace
use "...IAMR74FL.DTA", clear
keep mv0*
save MR.dta, replace
use "...IAPR74FL.DTA", clear
keep hv0* hvidx
save PR.dta, replace
* Prepare IR file for merge
use IR.dta, clear
gen in_IR=1
tab1 in*
gen state=v024
gen cluster=v001
gen hh=v002
gen line=v003
sort state cluster hh line
save IRtemp.dta, replace
* Prepare MR file for merge
use MR.dta, clear
gen in_MR=1
tab1 in*
gen state=mv024
gen cluster=mv001
gen hh=mv002
gen line=mv003
sort state cluster hh line
save MRtemp.dta, replace
* Prepare PR file for merge
use PR.dta, clear
gen in_PR=1
tab1 in*
gen state=hv024
gen cluster=hv001
gen hh=hv002
gen line=hvidx
sort state cluster hh line
* Merge PR with IR
merge state cluster hh line using IRtemp.dta
rename _merge merge_PR_IR
sort state cluster hh line
* Merge with MR
merge state cluster hh line using MRtemp.dta
rename _merge merge_PR_MR
sort state cluster hh line
save IRMRPR.dta, replace
tab1 in* merge*
|
|
|