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
Sorting a variable by two dummy variablesI am working on a paper about discrimination in the labour market. I have three variables (among man…
Measurement error when a variable is in bucketsHello, I've got a variable, AGE, which in my data set is given in buckets. Meaning someone with AGE…
Basic question on how to draw a vertical line that splits the distribution in a histogramHi all I am stuck in a basic procedure with histograms and hope someone can help. I used the follow…
Survival analysis: information before the observation time?Dear all, I am doing a survival analysis on companies performance from year 1980 to 2010. I want to…
Sufficient control for seasonality?Hello, I have a question about how to remove seasonality in Panel data. I want to evaluate how sales…
Subscribe to:
Post Comments (Atom)
0 Response to Splitting episodes & merging
Post a Comment