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: Drop observations of groups with gaps in their data


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Drop observations of groups with gaps in their data
Date   Fri, 3 Jun 2011 10:54:23 +0100

bysort gvkey (year) : drop if _N < (year[_N] - year[1] + 1) 

Nick 
[email protected] 

Achmed Aldai

Below find an extract of my data set.


gvkey            year
1001            1985
1001            1986
1001            1987
1001            1990
1001            1991
1200            1986
1200            1987
1200            1988
1200            1989


I want to drop all the firms that have a gap in reporting (gvkey = firm code). This means that all firms which e.g. reported from 1985 to 1987 and then again from 1990 to 1991 have to be dropped. Those companies should completely be eliminated from the data set, meaning stata should drop all observations of this company. So in the end I am left with the companies that do not have any gaps in reporting.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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