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
PPML with fixed effectsHi everyone! I am researching for my thesis about the trade impact of non-tariff measures. For that…
How to get Spatial Weight Matrix?Hello Everyone, I hope you are safe in your places. I am using Cross -Sectional data from the World…
postestimation command "Adjust" after Logit model with categorical variables as controlHi, I have a question about using adjust after running Logit model with categorical variables as con…
Help with replacing values of variable with conditionsDear Stata users, I want to replace the values of variable with conditions. This is the example of …
Scatter Plot AxisHi, I have done a scatter plot where the X-axis starts from the negative of Y. How to bring X-axis …
Subscribe to:
Post Comments (Atom)
0 Response to Splitting episodes & merging
Post a Comment