| 
		
			| Merge wealth index 1999 TZ DHS [message #14119] | Tue, 20 February 2018 12:42  |  
			| 
				
				
					|  kpat Messages: 2
 Registered: January 2018
 | Member |  |  |  
	| I am trying to merge Wealth Index (WI) files with the 1999 DHS IR file.  The code works, but only matches 533 of over 12,000 observations. 
 Starting with the IR file, I used the following code (which worked for four other countries in the analysis):
 gen whhid = substr(caseid,1,12)
 merge m:1 whhid using "TZWI3AFL.DTA"
 
 Please advise.
 [Updated on: Tue, 20 February 2018 12:43] Report message to a moderator |  
	|  |  | 
	| 
		
			| Re: Merge wealth index 1999 TZ DHS [message #14121 is a reply to message #14119] | Tue, 20 February 2018 14:47  |  
			| 
				
				
					|  Bridgette-DHS Messages: 3230
 Registered: February 2013
 | Senior Member |  |  |  
	| Following is a response from Senior DHS Stata Specialist, Tom Pullum: 
 The following lines will work:
 
 
 set more off
use e:\DHS\DHS_data\WI_files\TZWI3AFL.dta, clear 
sort whhid
save e:\DHS\DHS_data\scratch\TZWItemp.dta, replace
use e:\DHS\DHS_data\IR_files\TZIR3AFL.dta, clear
gen whhid=substr(caseid,1,12)
sort whhid
merge whhid using e:\DHS\DHS_data\scratch\TZWItemp.dta
tab _merge
 |  
	|  |  |