Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Selecting within a subset of observations


From   Ada Keding <ada.keding@york.ac.uk>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: Selecting within a subset of observations
Date   Thu, 13 Jun 2013 09:52:45 +0100

Dear all,

I am trying to use min/max or similar within a subset of observations.

For example, I have one or more event dates for different identifiers:

ID     EventDate
1      01/03/2011
2      31/01/2011
2      05/09/2011
3      12/03/2011

Now I would like to create a variable that displays the latest event
date within each identifier.

ID     EventDate       LatestEventDate
1      01/03/2011      01/03/2011
2      31/01/2011      05/09/2011
2      05/09/2011      05/09/2011
3      12/03/2011      12/03/2011

I have tried a number of long-winded ways using 'duplicates' but have
not found a solution yet.

Any pointers are much appreciated.

Many thanks,

Ada


Ada Keding
The University of York
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index