version 9 capture log close set more off log using ehf5.log, replace use rrdat1, clear gen des = tfin ~= ti /*destination state*/ gen ts = 0 /*starting time*/ gen tf = tfin - tstart + 1 /*ending time*/ gen coho2 = tb >= 468 & tb <= 504 /*cohort 2*/ gen coho3 = tb >= 588 & tb <= 624 /*cohort 3*/ gen lfx = tstart - te /*labor force experience*/ gen pnoj = noj - 1 /*previous number of jobs*/ gen newid = _n stset tf, failure(des) id(newid) /*define single episode data*/ stsplit t1, at(60 (60) 420) /*split time-span records*/ by newid, sort: replace ts = tf[_n-1] if newid == newid[_n-1] stset tf, failure(des) id(newid) /*define single episode data*/ list newid id des ts tf t1 lfx in 1/20 /*first records of data file*/ gen lfx60=ts streg edu coho2 coho3 lfx pnoj pres lfx60, dist(exp) nohr /*fit parametric survival model*/ * different episode splits: lfx24 drop t1 ts lfx60 /*drop variables with different values across split observations*/ stjoin /*combine records*/ gen ts = 0 stsplit t1, at(24 (24) 420) by newid, sort: replace ts = tf[_n-1] if newid == newid[_n-1] stset tf, failure(des) id(newid) gen lfx24=ts streg edu coho2 coho3 lfx pnoj pres lfx24, dist(exp) nohr * different episode splits: lfx12 drop t1 ts lfx24 stjoin gen ts = 0 stsplit t1, at(12 (12) 420) by newid, sort: replace ts = tf[_n-1] if newid == newid[_n-1] stset tf, failure(des) id(newid) list newid id des ts tf t1 lfx in 1/20 gen lfx12=ts streg edu coho2 coho3 lfx pnoj pres lfx12, dist(exp) nohr log close