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: RE: Keep first observation in such a dataset?


From   "Sarah Edgington" <[email protected]>
To   <[email protected]>
Subject   st: RE: Keep first observation in such a dataset?
Date   Tue, 11 Feb 2014 14:56:21 -0800

Peter,
I'm not sure I understand your data but it sound to me like maybe you want something as simple as:
keep if EVENT_DATE==DATE

If this isn't what you want, I think you'll probably need to explain in more detail what your full data set looks like and what  additional rules you need to implement when selecting observations to keep.

-Sarah



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Peter Miller
Sent: Tuesday, February 11, 2014 1:39 PM
To: [email protected]
Subject: st: Keep first observation in such a dataset?

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/


*
*   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