Project

General

Profile

Support #1826 ยป Socioeconomic status.do

 
use "*\i_youth.dta"
** Remove * and replace "filepath of your working directory"
** with the filepath where you want to save all files
** That is your working directory.
** Remember to include the double quotes
ren pidp pidp_y
**In this example natural father pidp is choosen
ren i_fnpid pidp
order pidp_y pidp
** Individual income estimates are included in the individual level data files, *_indresp.
merge m:1 pidp using "\i_indresp.dta"

**For Covid-19 survey
use "*\cf_youth_p.dta"
ren pidp_c pidp

**Parent identifiers**
merge 1:1 pidp using "*\h_indall.dta", keepusing(h_fnpid h_mnpid h_pn1pid h_pn2pid h_pns1pid h_pns2pid h_fnspid h_mnspid)

**Drop using observations
drop if _merge==2
ren _merge h_merge

**Generate a variable to identify if all observations from cf_youth_p.dta match *_indall to have parent identifiers
gen merge =3 if h_merge==3

**Repeat the process for the rest of the waves
merge 1:1 pidp using "*\*_indall.dta", keepusing(*_fnpid *_mnpid *_pn1pid *_pn2pid *_pns1pid *_pns2pid *_fnspid *_mnspid)
drop if _merge==2
ren _merge *_merge
replace merge =3 if *_merge==3 & merge==.

**In this example natural father pidp is choosen
**Repeat the process for the rest of the waves
gen fnpid = h_fnpid
replace fnpid = i_fnpid if fnpid==.
replace fnpid = *_fnpid if fnpid==.

ren pidp pidp_c
ren fnpid pidp

** Individual income estimates are included in the individual level data files, *_indresp.
merge m:1 pidp using "\*_indresp.dta"
    (1-1/1)