Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: reduce panel data set to survival data


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: reduce panel data set to survival data
Date   Tue, 7 Jul 2009 23:34:54 +0200

<> 



*************
bys Id (year): keep if _n==_N
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
[email protected]
Gesendet: Dienstag, 7. Juli 2009 23:32
An: [email protected]
Betreff: st: reduce panel data set to survival data

Dear statalist,

because I have only timeinvariant covariats I would like to reduce my 
panel data set (structure see below) to an cross sectional data set.

The structure of my panel data set: 

Id      year    Status  Survivaltime    x1      x2
1       2000    0       1003
1       2001    0       1003
1       2002    1       1003

2       2003    0       298
2       2004    2       298

3       1998    0       3989 
3       1999    0       3989
3       2000    0       3989
3       2001    0       3989
3       2002    0       3989
3       2003    0       3989
3       2004    0       3989
3       2005    0       3989

Desired structure of data set:

Id      year    Status  Survivaltime    x1      x2
1       2002    1       1003

2       2004    2       298

3       2005    0       3989

I would like to keep only the last observation (which give me the outcome 
of survival or death). My problem is now, that the outcome does not occure 
always in the same year (as you can see it can happen in 2002 or 2005 or 
whenever between 1998 and 2008). The other problem I face is, that I can 
not use the command drop if status==0 because 0 can be also the desired 
outcome in the last year.

Does anybody know how I could keep the last observation and drop all other 
observation? 

Thank you so much for your help.

Best regards 
Frauke




___________________________________

Frauke Rüther, Dipl.-Kffr., M.A.
Research Associate
University of St.Gallen
Institute of Technology Management
Dufourstrasse 40a
CH - 9000 St. Gallen

Phone   +41 (0)71 224 7225
Fax        +41 (0)71 224 7301
Email    [email protected]
Web      www.item.unisg.ch

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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