Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Removing a panel observation if it does not have an entry for a certain period |
Date | Wed, 8 Jan 2014 01:19:00 +0000 |
<> bysort cert : egen present30 = total(period == 30) drop if cert == 0 drop present30 See also http://www.stata-journal.com/article.html?article=dm0055 Nick njcoxstata@gmail.com On 8 January 2014 00:48, Travis Cyronek <hagendaasmaser@gmail.com> wrote: > I am using an unbalanced panel with a total > of about 450000 observations. These observations are of roughly 16000 > banks over 44 quarters. My panel variable is cert (FDIC certification > number, assigned to banks with FDI) and my time variable is period (1 for > the first quarter in my study, and 44 for the last quarter in my study). > > I am looking at the effect of a piece of legislation passed during this > time frame using a dummy variable. However, the data I have include banks > that exited the market before this change and also includes banks that > entered the market after. I would like to remove the banks that do not have > observations for the period when the legislation was passed (for example, > say period 30). > > All that I have found as far as removing variables involves removing > individual observations. I, however, would like to remove the entire set of > observations for bank i IF it does not have an observation for period 30. > > Given that my data file is huge, manually going through each of the 16000 > banks to see if there is an entry for period 30 is not practical. So I > was wondering how I would go about this. * * 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/