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 on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: Dropping all subjects but those in the last period


From   "Cohen, Elan" <cohened@upmc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Dropping all subjects but those in the last period
Date   Mon, 8 Apr 2013 19:39:35 +0000

Let's assume 2010 is the "last year".  Then:

egen flag = total(year==2010), by(id)
drop if !flag

HTH,

- Elan


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Miguel Angel Duran
Sent: Monday, April 08, 2013 15:27
To: statalist@hsphsun2.harvard.edu
Subject: st: Dropping all subjects but those in the last period

My dataset includes observations for about 9000 companies per year in a
twenty years period. To clean the dataset, I would like to drop all those
companies that are not present in the last year (because the rest went
bankrupt or were absorbed), but I do not know how to do it. Can this be done
just by splitting the datasets by period and then merging them?  Each
company has the same id across years. Thanks.

Miguel A. Duran.

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