Hello Statalist members,
I have a question about how to drop multiple observations from the same ID (or only keep one observation per ID). For example, my current data looks like this:
ID. Year
1 2010
1 2012
1 2014
2. 2008
3. 2011
3. 2014
4. 2007
4. 2009
4. 2012
5. 2007
I only want to keep the observation for the earliest Year (or drop the observations for the later Years) and I hope my new data would look like this:
ID. Year
1. 2010
2 2008
3 2011
4 2007
5 2007
Could you please let me know what code should I use?
Many thanks
Yuchen
I have a question about how to drop multiple observations from the same ID (or only keep one observation per ID). For example, my current data looks like this:
ID. Year
1 2010
1 2012
1 2014
2. 2008
3. 2011
3. 2014
4. 2007
4. 2009
4. 2012
5. 2007
I only want to keep the observation for the earliest Year (or drop the observations for the later Years) and I hope my new data would look like this:
ID. Year
1. 2010
2 2008
3 2011
4 2007
5 2007
Could you please let me know what code should I use?
Many thanks
Yuchen
Comment