55 lines
1.5 KiB
Plaintext
55 lines
1.5 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)
|
|
gen refdate = $refdate + 180
|
|
drop if refdate < obs_de_date
|
|
gen period = qofd(refdate )-qofd(obs_de_date) +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
|
|
sort individid
|
|
gen fatherid =individid
|
|
gen motherid = individid
|
|
gen partnerid = individid
|
|
|
|
gen foccupationid = occupationid
|
|
gen moccupationid = occupationid
|
|
gen poccupationid = occupationid
|
|
tostring quarterdate, generate(key)
|
|
replace key = individid + key
|
|
duplicates drop key, force
|
|
drop _merge
|
|
sort key
|
|
save crossOccupationtemp, replace
|
|
keep if refquarter == quarterdate
|
|
format refdate %td
|
|
keep individid fatherid motherid partnerid occupationid foccupationid moccupationid poccupationid refdate obs_de_date observeid
|
|
duplicates drop individid, force
|
|
sort individid
|
|
save cross\crossoccupation, replace
|
|
keep partnerid poccupationid refdate
|
|
sort partnerid
|
|
save cross\crosspoccupation, replace
|
|
use cross\crossoccupation
|
|
keep motherid moccupationid refdate
|
|
sort motherid
|
|
save cross\crossmoccupation, replace
|
|
use cross\crossoccupation
|
|
keep fatherid foccupationid refdate
|
|
sort fatherid
|
|
save cross\crossfoccupation, replace
|
|
|
|
|
|
|
|
|