Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: finding the last observation in a survival dataset


From   Svend Juul <[email protected]>
To   <[email protected]>
Subject   Re: st: finding the last observation in a survival dataset
Date   Sun, 27 Apr 2008 21:18:03 +0200

Michael McCulloch wrote:
 
I would like to learn how to identify the last observation 
of each individual subject within a longitudinal data set.
I'm using the hip2.dta data set, and have run _stsplit_ to 
create one observation per failure time for each subject. 
Note that subject id==1 observed a failure during observation 
time, whereas subject id==48 did not.
 
use hip2.dta, clear
stsplit, at(failures) riskset(riskid)
sort id time0
list id time0 time1 protect fracture if id==1 | id==48
 
In order to estimate a subject's probability of being 
censored, I will create a new variable, C, which is equal to 
zero for a subject's last failure time if the subject was not 
censored, and is equal to one subject was censored.
 
How can I identify the last observation of each individual 
subject within a longitudinal data set, so that I can create 
my new variable without having to manually search for that 
last observation?
 
==============================================================
 
Using the example from [ST] stsplit:
 
webuse diet.dta , clear
stset dox , failure(fail) origin (time dob) enter(time doe) scale(365.25) id(id)
stsplit ageband , at(40(10)70)
bysort id (_t) : egen maxt = max(_t)
 
Now, the last observation period for each person is the period
where maxt == _t.
 
Hope this helps
Svend

________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:   +45 8942 6090 
Phone, home:   +45 8693 7796 
Fax:           +45 8613 1580 
E-mail:        [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/



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