********************************** ** NIGERIA MERGING INSTRUCTIONS ** ** IPUMS-DHS, January 2017 ******* ** 2003, 2008, and 2013 ********** ********** ** 2013 ** ********** use NGKR6AFL.DTA, clear * 1. Generate SAMPLE (as a number rather than a string) gen sample=5665 * 2. Adjust width of CASEID * No leading blanks in original data - add them and make appropriate width replace caseid=substr(" ", 1, 15 -length(caseid)) + caseid * 15 spaces in the quotation marks above * 3. Generate IDHSPID & IDHSPIDK * IDHSPID: unique identifier for women/respondents gen idhspid=" "+string(sample)+caseid * 3 spaces in the quotation marks above * IDHSPIDK: unique identifier for children gen idhspidk=idhspid + string(bidx) save ng2013.dta, replace ********** ** 2008 ** ********** use NGKR52FL.DTA, clear * 1. Generate SAMPLE gen sample=5664 * 2. Generate IDHSPID & IDHSPIDK gen idhspid=" "+string(sample)+caseid gen idhspidk=idhspid + string(bidx) save ng2008.dta, replace ********** ** 2003 ** ********** use NGKR4BFL.DTA, clear * 1. Generate sample gen sample=5663 * 2. Generate IDHSPID & IDHSPIDK gen idhspid=" "+string(sample)+caseid gen idhspidk=idhspid + string(bidx) save ng2003.dta, replace * 3. Append * ng2008 and ng2013 have IDHSPID and IDHSPIDK append using ng2008.dta append using ng2013.dta save ng_dhs.dta, replace *************** ** IPUMS-DHS ** *************** **Use filename of your IPUMS-DHS extract (such as idhs_00001.dta) use nigeria_ipums.dta, clear * 1. Generate IDHSPIDK gen idhspidk=idhspid + string(bidx) *2. Merge original DHS data merge 1:1 idhspidk using ng_dhs.dta save nigeria_merged.dta, replace