Statalist


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

st: finding the last observation in a survival dataset


From   Michael McCulloch <[email protected]>
To   Statalist <[email protected]>
Subject   st: finding the last observation in a survival dataset
Date   Sun, 27 Apr 2008 09:36:11 -0700

Hi,
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?


--

Best wishes,
Michael McCulloch



Pine Street Foundation
124 Pine St., San Anselmo, CA 94960-2674
Tel: (415) 407-1357
Fax: (415) 485-1065
[email protected]
www.pinestreetfoundation.org
*
* 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