Dear Statalist.
Firstly I am relatively new to Stata.
I have a list with patients IDs, dates and lots of other data.
Now I have sorted the list in Patient ID and then dates (of the observation) 'sort ID Date'.
I need to be able to drop ALL BUT the earliest date in my dataset for each patient ID. How is this achieved?
eg.
ID Date
1 01/01/2000 <keep
1 10/06/2011
1 22/03/2017
2 30/09/2003 <keep
2 12/10/2010
3 06/02/2001 <keep
3 28/08/2005
3 11/02/2009
3 15/05/2015
to this
ID Date
1 01/01/2000
2 30/09/2003
3 06/02/2001
Furthermore if need be, is it possible to tell STATA to only keep a specific date on a single patient and discard the rest?
To use the example above.
for patient ID 1 Keep date nr 2 (10/06/2011)
for ID 2 keep Date nr 2 (12/10/2010)
for ID 3 keep the last date nr 4 (5/05/2015).
Thanks
Regards
Puriya
Firstly I am relatively new to Stata.
I have a list with patients IDs, dates and lots of other data.
Now I have sorted the list in Patient ID and then dates (of the observation) 'sort ID Date'.
I need to be able to drop ALL BUT the earliest date in my dataset for each patient ID. How is this achieved?
eg.
ID Date
1 01/01/2000 <keep
1 10/06/2011
1 22/03/2017
2 30/09/2003 <keep
2 12/10/2010
3 06/02/2001 <keep
3 28/08/2005
3 11/02/2009
3 15/05/2015
to this
ID Date
1 01/01/2000
2 30/09/2003
3 06/02/2001
Furthermore if need be, is it possible to tell STATA to only keep a specific date on a single patient and discard the rest?
To use the example above.
for patient ID 1 Keep date nr 2 (10/06/2011)
for ID 2 keep Date nr 2 (12/10/2010)
for ID 3 keep the last date nr 4 (5/05/2015).
Thanks
Regards
Puriya
Comment