Project

General

Profile

Support #2105 ยป linking forum.do

 
//define paths
global pathdata "path to your data"
cd "path to your working folder"
//open wave 13, fimngrs_dv used as an example
use pidp *fimngrs_dv *fnpid *mnpid using "$pathdata/ukhls/m_indresp", clear

/////PART A - Father
//step 1. renaming pidp, necessary for step 2
rename pidp childpidp
//step 2. renaming fnpid to pidp, necessary to use it to link to father's BHPS wave 1 pidp
rename m_fnpid pidp
//step 3. fnpid is the pidp of the natural father, so we now be linking the child to the father
merge m:1 pidp using "$pathdata/bhps/ba_indresp", keepusing (ba_fimngrs_dv)
// dropping respondents in BHPS wave 1 with no matches, in other words, there are no children of those respondents in the wave 13 UKHLS sample
drop if _merge==2
drop _merge
//making clear that ba_fimngrs_dv refers to the father, necessary for the mothers part below to work
rename ba_fimngrs_dv ba_fimngrs_dv_father
//renaming "pidp" back to fnpid
rename pidp m_fnpid

/////PART B - MOTHER - the steps are identical as above
rename m_mnpid pidp
merge m:1 pidp using "$pathdata/bhps/ba_indresp", keepusing (ba_fimngrs_dv)
drop if _merge==2
drop _merge
rename ba_fimngrs_dv ba_fimngrs_dv_mother

//renaming variables back to their original names
rename pidp m_mnpid
rename childpidp pidp

    (1-1/1)