******************************************************************************** * Created by: Clinton Hayes * * Updated by: Nicole Watson & Markus Hahn * * * * Purpose of the progam: * * ====================== * * This program demonstrates how to merge the partner information to the * * responding person file. Wave 1 data is used here as an example. * * Please note that we use 'tempfile partner' to create a macro (local) that * * allows us to access a temporary data file which will be automatically * * deleted when this do-file ends. * ******************************************************************************** clear set memory 1g // Specify directories (use "." to point to current directory) local origdatadir "C:\orig-data" // Location of original HILDA data files local newdatadir "C:\new-data" // Location to which to write new data files // Prepare a data set with partner information use "`origdatadir'\Rperson_a140c.dta" keep ahhpxid ahgage ahgsex // keep the variables wanted drop if ahhpxid=="" // drop persons who have no partner rename ahhpxid xwaveid // rename matching indicator rename ahgage apartage // rename age variable rename ahgsex apartsex // rename sex variable tempfile partner save "`partner'", replace // save to temporary partner file // Merge responding persion file with partner file use "`origdatadir'\Rperson_a140c.dta" merge 1:1 xwaveid using "`partner'" drop if (_merge==2) // cases can't be merged because partner is non-respondent drop _merge // Save new data set save "`newdatadir'\rperson-partner", replace