gen i1=0
replace i1=1 if (time==0&case==0)
could be condensed to
gen i1 = time == 0 & case == 0
The three -generate-s could be
done at once, modulo a change
of names:
forval j = 1/3 {
gen i`j' = time == `j' & case == 0
}
So,
gen id=_n
stset year, failure(hd==1) id(id)
stsplit time, at(1,2)
forval j = 1/3 {
gen i`j' = time == `j' & case == 0
}
stcox i0 i1 i2 age1 age2 gender c1 c2
Nick
[email protected]
Claus Dethlefsen
Thanks to Beno�t Laplante, I was pointed towards the manual on "stsplit" and I am now able to reproduce the output from SAS in my Stata program. In case others are interested, here is my solution
/* Attempt 4 */
gen id=_n
stset year, failure(hd==1) id(id)
stsplit time, at(1,2)
gen i1=0
replace i1=1 if (time==0&case==0)
gen i2=0
replace i2=1 if (time==1&case==0)
gen i3=0
replace i3=1 if (time==2&case==0)
stcox i1 i2 i3 age1 age2 gender c1 c2
I am quite sure, that this could be done more elegantly, but I'm still learning.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/