Hello Statalist
Here is my example data:
Here is an example from my code:
Training and age are not important in stset. Begin variable is for entering to the risk and end is an event variable. I think using enter(var) or origin(var) would not give me a discontinuous risk and here lies the problem. I have been able to stset my data with using enter or origin options, but time0 has been more problematic.
I have read statalist etc. but usually the time0(var) data is imputted to stset as an variable which states the time of entering for example to job market (so becomes at risk of being unemployed), and not in binary marker variable. I am now attending to make this variable to one which states the time of entering.
I am new to the survival analysis and I am asking is this a working way of stset my data or would there be a better way of doing it?
Thank you in advance for your responses.
Here is my example data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id year begin end training age condition) 1 1 1 0 1 10 1 1 2 0 1 1 11 0 1 3 0 0 1 12 0 1 4 1 0 1 13 1 1 5 0 1 1 14 0 1 6 0 0 1 15 0 2 1 1 0 0 21 1 2 2 0 0 0 22 1 2 3 0 1 0 23 0 3 1 1 0 1 30 1 3 2 0 0 1 31 1 3 3 0 1 1 32 0 3 4 1 0 1 33 1 3 5 0 1 1 34 0 4 1 0 0 0 1 0 4 5 0 0 0 5 0 5 1 0 0 0 60 1 5 2 0 0 0 61 1 5 3 0 1 1 62 1 5 5 0 0 1 65 0 end
Code:
sort id year snapspan id year end begin, generate(time0) replace gen timebegin = time0 if begin==1 replace timebegin=1 if condition==1&time0==1 stset year, failure(end) exit(time .) id(id) time0(timebegin)
I have read statalist etc. but usually the time0(var) data is imputted to stset as an variable which states the time of entering for example to job market (so becomes at risk of being unemployed), and not in binary marker variable. I am now attending to make this variable to one which states the time of entering.
I am new to the survival analysis and I am asking is this a working way of stset my data or would there be a better way of doing it?
Thank you in advance for your responses.