Statalist The Stata Listserver


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

st: convert survival data to panel data


From   "Matthias Kredler" <mk1168@nyu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: convert survival data to panel data
Date   Thu, 17 May 2007 15:22:33 -0400

Hi there

My problem is that I have survival-type data (which I can
stset) with several spells for one individual, and I'd like
to convert them into a panel (I would transfer the
characteristics from the spell that goes around the
date of interest, say Jan 1 00, Feb 1 00, etc., into
my panel, creating a record with the person identifier,
the respective date, and the other characteristics
recorded in the spell.) Is there a command that can do this in one
step? I've checked all the "st..."-type command, and
I couldn't find any...

An example:

The survival type data: for an individual with an identifier "ID",
where the spell starts at "st" and ends at "end", with another
variable "x" associated with the spell:

ID  st  end x
1   10  13  a
1   13  17  b
2   10  15  b
2   15  17  a

My desired output in panel form: At time 12, 14, 16, give me the "ID" if there
is a spell for this individual and copy the variable "x" from the
respective spell:

t   ID  x
12  1   a
12  2   b
14  1   b
14  2   b
16  1   b
16  2   a

I could write a loop over the n dates of interest, create n cross-section
files and then put them into one panel, but it would be great if somebody
knew something faster...

Thanks a lot
Matthias
*
*   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