Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Solved: stcox and tvc. Translation of SAS program


From   "Claus Dethlefsen / Aalborg Sygehus" <[email protected]>
To   <[email protected]>
Subject   st: Solved: stcox and tvc. Translation of SAS program
Date   Tue, 14 Jun 2005 18:42:40 +0200

Dear list
 
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.
 
Best,
Claus
 
________________________________
Claus Dethlefsen, Msc, PhD
Statistiker ved Kardiovaskul�rt Forskningscenter

Klinisk Epidemiologisk Afdeling
Aalborg Sygehus Nord
Stengade 10, 2. sal
9000 Aalborg

Tlf:   9932 1086
       9932 1094 (direkte)
Fax:   9932 1088
email: [email protected] <mailto:[email protected]> 

________________________________

Fra: [email protected] p� vegne af Claus Dethlefsen / Aalborg Sygehus
Sendt: ma 13-06-2005 13:50
Til: [email protected]
Emne: st: stcox and tvc. Translation of SAS program



Dear list

I have difficulties translating a SAS program into Stata. I am fairly
new to Stata, and also to survival analysis, but hope that I can get
some help from the list.

The situation from survival analysis. Events are registred in the
binary variable hd, and time-to-event in the continuous variable
year. The variables age1, age2, gender, c1 and c2 are binary
variables. The variable case is also binary.

This is the SAS program:

proc phreg data = test2;
 model year*hd(0) = i1 i2 i3 age1 age2 gender c1 c2/risklimits ;
  if year<1 and case=0 then i1=1;else i1=0;
  if 1<=year<=2 and case=0 then i2=1;else i2=0;
  if year>2 and case=0 then i3=1;else i3=0;
 ods output parameterestimates = oddsm;
run;

As I interpret this, the baseline hazard rates are different in the
three intervals defined by i1 i2 and i3, adjusted for the remaining
covariates.

These are my Stata attempts:

/* Common to the code below */
gen i1=0
replace i1=1 if (year<1&case==0)
gen i2=0
replace i2=1 if (year>=1&year<=2&case==0)
gen i3=0
replace i3=1 if (year>2&case==0)

/* Attempt 1 */
stset year, failure(hd==1)  /* note that SAS has the opposite hd==0 */
stcox  i1 i2 i3 age1 age2 gender c1 c2

This does not work, since the SAS code implies different baseline
hazards in the three periods defined by inter1-3.

/* Attempt 2 */
stset year, failure(hd==1)
stcox  i1 i2 i3 age1 age2 gender c1 c2, tvc(i1 i2 i3)

or

stcox  age1 age2 gender c1 c2, tvc(i1 i2 i3)

I am not certain whether my use of tvc() is correct (and equivalent to
the SAS approach). At least, the estimates are very different.

/* Attempt 3 */

gen id=_n
stset year, failure(hd==1) id(id)
stcox i1 i2 i3 age1 age2 gender c1 c2

or

stcox i1 i2 i3 age1 age2 gender c1 c2, tvc(i1 i2 i3)

None of the attempts produce estimates anywhere near the output from
SAS. I am probably missing some options or have misunderstood their
use. I would appreciate help to get on.

I am using the latest Stata 9, updated to the most recent version.

Best,
Claus
_______________________________

Claus Dethlefsen, Msc, PhD
Statistiker ved Kardiovaskul�rt Forskningscenter
Klinisk Epidemiologisk Afdeling

Aalborg Sygehus Nord
Stengade 10, 2. sal
9000 Aalborg

Tlf:   9932 1086
       9932 1094 (direkte)
Fax:   9932 1088
email: [email protected]



*
*   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/


<<winmail.dat>>




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index