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

 From Steven Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: finding the last observation in a survival dataset Date Sun, 27 Apr 2008 14:58:34 -0400

Michael,

That will be the "time" variable in your -stset- command. If you have multiple-time observations, it is the highest one.

-Steven
On Apr 27, 2008, at 2:21 PM, Michael McCulloch wrote:

Sorry Maarten that I didn't fully explain my question. I will be estimating the probability of being censored using a Cox regression, with
dependent variable: C==0/1 in the last observation time for each subject
predictor variables: baseline covariates
It's for the method by Robins, 2000 called "Inverse Probability of Censoring Weighting."
That's why I want to find the last observation time for each subject.
Michael

```-stdes- will give you that proportion.

-- Maarten

--- Michael McCulloch <mm@pinest.org> wrote:

```
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
mcculloch@pinestreetfoundation.org
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/

```
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

__________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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/
```
```*
*   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/
```