Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Keep first observation in such a dataset?


From   "Peter Miller" <peter_miller@gmx.ch>
To   statalist@hsphsun2.harvard.edu
Subject   st: Keep first observation in such a dataset?
Date   Tue, 11 Feb 2014 22:39:04 +0100 (CET)

Hi guys,

this is my dataset:

DATE      ID1         ID2    EVENT_DATE
8/13/2007 10147      95574   13aug2007
8/14/2007 10147              13aug2007
8/15/2007 10147              13aug2007
8/16/2007 10147              13aug2007
8/17/2007 10147      75645   13aug2007
8/20/2007 10147              13aug2007
.....             ......
 
I want to keep only the first ID2. In the example, I want to keep 95574 only. Only the one, which is between DATE and EVENT_DATE. I want to drop all following ID2s in the time series. There are many different ID1s, but each ID1 belongs to only one single ID2, namely the one where EVENT_DATE==DATE. 
 
How can I code this?
 
Thanks

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index