Home » Data » Merging data files » Merge WI to KR in Mali
|
|
Re: Merge WI to KR in Mali [message #17925 is a reply to message #17898] |
Thu, 18 July 2019 09:42 |
Bridgette-DHS
Messages: 3216 Registered: February 2013
|
Senior Member |
|
|
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:
Merges involving these two surveys in Mali are difficult because they included a "sub-household" code. Fortunately, the subsequent surveys in Mali did not have this complication. (A couple of non-Mali surveys have the same problem.)
However, for what you want to do, you can bypass the HR file completely. You can merge the WI and KR files directly. It helps that the wealth index is the same for all sub-households within a household so you don't have to distinguish the sub-households. For some other merges with these surveys, you do need to do that.
The following lines show how to do this with the 1995-96 survey. You will have to change the paths. The basic strategy is to use the household id code. First you need to unpack the columns of whhid in the WI file and caseid in the KR file. I find that columns 1-12 of caseid are a match with columns 1-12 of whhid. This "unpacking" strategy will virtually always work for a merge that is giving you a problem.
* Procedure to transfer the wealth index from WI to KR without using HR
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\MLWI32FL.DTA", clear
describe whhid
list if _n<=20, table clean
* I want to identify the separate columns of whhid
local li=1
while `li'<=12 {
gen str1 col`li'=substr(whhid,`li',1)
local li=`li'+1
}
list whhid col* if _n<20, table clean
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\MLKR31FL.DTA", clear
describe caseid
list caseid if _n<=20
* I want to identify the separate columns of caseid
local li=1
while `li'<=15 {
gen str1 col`li'=substr(caseid,`li',1)
local li=`li'+1
}
list caseid col* if _n<20, table clean
* It appears that columns 1-12 of caseid in the KR file match with columns 1-12 of whhid in the WI file
* Now do the merge
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\MLWI32FL.DTA", clear
gen mergeid=whhid
sort mergeid
save e:\DHS\DHS_data\scratch\MLWItemp.dta, replace
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\MLKR31FL.DTA", clear
gen mergeid=substr(caseid,1,12)
sort mergeid
merge mergeid using e:\DHS\DHS_data\scratch\MLWItemp.dta
tab _merge
keep if _merge==3
drop _merge
summarize wlthind*
|
|
|
Re: Merge WI to KR in Mali [message #17931 is a reply to message #17896] |
Thu, 18 July 2019 13:11 |
boyle014
Messages: 78 Registered: December 2015 Location: Minneapolis
|
Senior Member |
|
|
You might consider using IPUMS DHS for a task like this. If you select children as your unit of analysis, the household wealth index is already available without doing any file merging. In addition, you will get a single file with all samples appended and all variables harmonized.
Professor Elizabeth Boyle
Sociology & Law, University of Minnesota, USA
Principal Investigator, IPUMS-DHS
|
|
|
Goto Forum:
Current Time: Thu Jan 2 01:42:08 Coordinated Universal Time 2025
|