28 lines
939 B
Plaintext
28 lines
939 B
Plaintext
clear all
|
|
cd c:\chililabdata\data
|
|
use individres.dta
|
|
gen sround = substr( res_sobserveid, 10,3)
|
|
destring sround, replace
|
|
drop res_sobserveidGuid res_eobserveidGuid
|
|
gen eround ="023" if res_eobserveid==""
|
|
replace eround = substr( res_eobserveid, 10,3) if res_eobserveid !=""
|
|
destring(eround), replace
|
|
duplicates drop individid res_sobserveid,force
|
|
duplicates drop individid eround,force
|
|
gen period = eround - sround
|
|
expand period
|
|
sort individid locationid sround
|
|
by individid locationid sround: gen step=_n-1
|
|
gen round = sround + step
|
|
duplicates drop individid round, force
|
|
drop if round > 22
|
|
tostring round, replace
|
|
replace round = "00" + round if strlen(round) == 1
|
|
replace round ="0" + round if strlen(round)==2
|
|
gen individkey = individid + round
|
|
sort individkey
|
|
drop res_episodeid res_seventtype res_sdate res_sobserveid res_eeventtype res_eobserveid res_edate sround eround period step
|
|
save ..\newcode\data\std_recidency, replace
|
|
|
|
|