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
Measures to compare distributions and the Probability-Probability-PlotHi Statalisters, I want to compare the distributional fit of predicted values with the original dat…
learning Stata's postestimation toolsHi Statalist I recently watched Kristin MacDonald's webinar 'Stata Tips and Tricks' and there was a…
Adding a list of variables to each observationHow do I add a list of variables from a “using” file to every observation (for a list of entities) i…
Can I use distrate for clustered data?Hello, I have data with number of health conditions entered as binary variables 1 (Yes) or 0 (No), e…
new var calculated from group means of survey dataGreetings, I working on Stata 15 with survey data using pweights. I have created the bar graph belo…
Subscribe to:
Post Comments (Atom)
0 Response to Splitting episodes & merging
Post a Comment