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

Re: st: setting up survival data


From   Allen Buxton <abbuxton@pacbell.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: setting up survival data
Date   Tue, 25 Nov 2003 14:19:10 -0800 (PST)

I think you can only stset with one origin. 

I wrote a function, survtime, to find a event date and
corresponding indicator for one or more events or
censors. 
If you have any interest, I would be happy to share
it. 
An example of the syntax is in comments /* ... */
below


generate dolast=dodischg+90
assert dolast~=. /* everyone must have a valid censor
point */
gen temp0=(doreadm<=dolast)
gen byte readmit=temp0
gen readmit_d=doreadm if temp0==1
replace readmit_d=dolast  if temp0==0
gen readmit=1 if temp0==1
replace readmit=0 if temp0==0
drop temp0

/* survtime, event(doreadm) censor(dolast) seq
generate(readmit) */
stset readmit_d, failure(readmit==1) origin(doadmit)
id(ptid) scale(30.4) /* e.g. scale _t for months */

-Allen Buxton


--- Alexander Tsai <act2@cwru.edu> wrote:
> Dear Statalisters,
> 
> I have data on patients, readmissions, and deaths:
> 
> . list ptid doadmit doreadm dod
> 
>       
>
+----------------------------------------------------+
>        |       ptid       doadmit     doreadm       
>    dod |
>       
>
|----------------------------------------------------|
>     1. |   00000125   29 Aug 1996   14 Nov 96   20
> Oct 1997 |
>     2. |   00000133   20 Jul 1991           .       
>      . |
>     3. |   00000491   21 Mar 1997           .   26
> Jun 1999 |
>     4. |   00000865   06 Mar 1996           .       
>      . |
>     5. |   00000932   13 May 1997   11 Jul 97       
>      . |
>       
>
|----------------------------------------------------|
>     6. |   00001354   04 Jun 1994           .       
>      . |
>     7. |   00001610   10 May 1995           .       
>      . |
>     8. |   00001804   24 Sep 1996           .   12
> Jul 1997 |
>     9. |     000020   20 Aug 1992           .   09
> Sep 1993 |
>    10. |     000025   28 Oct 1996           .   24
> Aug 1999 |
>       
>
|----------------------------------------------------|
>    11. |     000034   20 Nov 1992   07 Jan 93       
>      . |
> 					...
> 
> I want to examine readmissions only up to 90 days
> post-discharge, so I
> create an extra variable, 'dolast':
> 
> 	generate dolast=dodischg+90
> 	format dolast %dD_m_CY
> 
> But all of the observations with doreadm==. are,
> obviously, missing. So
> when I -stset- my data, I obtain the following
> results:
> 
> . stset doreadm, id(ptid) time0(doadmit) origin(time
> doadmit)
> failure(event) exit(event==2 time dolast)
> 
>                 id:  ptid
>      failure event:  event != 0 & event < .
> obs. time interval:  (doadmit, doreadm]
>  exit on or before:  event==2 time dolast
>     t for analysis:  (time-origin)
>             origin:  time doadmit
> 
>
------------------------------------------------------------------------
> ------
>     23324  total obs.
>     18608  event time missing (doreadm>=.)          
>            PROBABLE
> ERROR
>
------------------------------------------------------------------------
> ------
>      4716  obs. remaining, representing
>      4716  subjects
>      4716  failures in single failure-per-subject
> data
>    184319  total analysis time at risk, at risk from
> t =         0
>                              earliest observed entry
> t =         0
>                                   last observed exit
> t =        90
> 
> What I would like to do is:
> 
> a) I would like to remove patients from the study if
> they die within 90
> days post discharge. But I can't have two time
> variables in the exit
> option -- for example, (exit time dod dolast). So
> what I did is set
> event==2 for death (event==1 for readmission).
> 
> b) How do I keep the patients with no readmission in
> the study? I
> thought about replacing doreadm=dolast if doreadm==.
> but that doesn't
> seem right.
> 
> Cleves/Gould/Gutierrez' book "An Introduction to
> Survival Analysis Using
> Stata" has been exceedingly helpful, but I am stuck
> here. I'd be
> grateful for any help.
> 
> Thanks,
> Alex
> 
> 
> 
> *
> *   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/

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



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