Hey Stata Community,
I need to split every job episode according to calendar years (rrdat dataset; monthly data starting from 1900) and then merge to this yearly subepisode the unemployment rate (UE dataset) of this particular year.
Here are the steps I have done so far:
gen start = 0
gen event = tfin != ti
gen tstart1 = 1900 + tstart/12
gen tstart2 = int(tstart1)
gen tfin1 = 1900 + tfin/12
gen tfin2 = int(tfin1)
tab tfin2 in 1/50
gen duration = tfin2 - tstart2 + 1
tab duration
gen newid = _n
stset duration, f(event) id(newid)
expand duration
by newid, sort: replace start = duration[_n - 1] if newid == newid[_n-1]
by newid, sort: gen year = tstart2[_n-1]+ _n-1 if newid==newid[_n-1]
replace year = tstart2 if year==.
However, after I merge the datasets and run stset duration, f(event) id(newid), Stata gives me a probable error.
Could you please advise what is wrong and how this can be fixed?
I appreciate any help!
Related Posts with Splitting episodes & merging
How i can interpret this model? *Prob > chi2 = * *0.0000 Code: * Model A . eststo A, title ("Model A"): xtmixed Y X2 X1 time c.X2#c.time c.X1#c.time grou…
helpI am working on a database containing the region variable. Is there a possibility to transform this …
Margins and Ologit2Hello, I am fitting a ologit2 model for an ordered outcome - HIVrisk (none, low and high). I am tryi…
HelpHi, it's not a question about stata, but maybe you can give me a guide. I am trying to get a histog…
Dynamic prediction after GARCHDear stata listers, I'm currently doing an event study using GARCH model to test the effects of cer…
Subscribe to:
Post Comments (Atom)
0 Response to Splitting episodes & merging
Post a Comment