Bookmark and Share

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

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

st: RE: Keep first observation in such a dataset?

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

I'm not sure I understand your data but it sound to me like maybe you want something as simple as:

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.


-----Original Message-----
From: [] On Behalf Of Peter Miller
Sent: Tuesday, February 11, 2014 1:39 PM
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?

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index