39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
use observation
|
|
sort observeid
|
|
save observation, replace
|
|
use occupation
|
|
keep individid occupationid occ_sobserveid
|
|
rename occ_sobserveid observeid
|
|
sort observeid
|
|
merge observeid using observation, nokeep keep (obs_de_date)
|
|
drop if $refdate < obs_de_date
|
|
gen period = qofd($refdate )-qofd($startdate ) +1
|
|
expand period
|
|
sort individid obs_de_date
|
|
by individid obs_de_date: gen p= _n-1
|
|
gen quarterdate = qofd(obs_de_date) + p
|
|
gen refquarter = qofd($refdate )
|
|
sort individid quarterdate
|
|
egen maxobs_de_date = max(obs_de_date), by(individid quarterdate)
|
|
keep if obs_de_date == maxobs_de_date
|
|
save crossOccupationtemp, replace
|
|
keep if refquarter == quarterdate
|
|
gen refdate = $refdate
|
|
format refdate %td
|
|
keep individid occupationid refdate obs_de_date observeid
|
|
duplicates drop individid, force
|
|
sort individid
|
|
save cross\crossoccupation, replace
|
|
rename individid fatherid
|
|
rename occupationid foccupationid
|
|
sort fatherid
|
|
save cross\crossfoccupation, replace
|
|
rename fatherid motherid
|
|
rename foccupationid moccupationid
|
|
sort motherid
|
|
save cross\crossmoccupation, replace
|
|
rename motherid partnerid
|
|
rename moccupationid poccupationid
|
|
sort partnerid
|
|
save cross\crosspoccupation, replace
|