Dear Stata Users,

I need to keep just those firms (gvkey) that have 3 year consecutive observations before and after the event. The event date observation is supposed to be accounted for "after" event, but not for the consecutive years of "before" event. For example, in the data below firms (gvkey) 1173 and 1266 satisfy this requirement. Please, help me with this issue.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long gvkey_destr int fyear float event
1121 2006 .
1121 2007 .
1121 2008 1
1121 2009 .
1121 2010 .
1121 2011 .
1121 2012 .
1121 2013 .
1173 2006 .
1173 2007 .
1173 2008 .
1173 2009 1
1173 2010 .
1173 2011 .
1173 2012 .
1210 2006 .
1210 2007 .
1210 2008 .
1210 2009 .
1210 2010 .
1210 2011 .
1210 2012 1
1210 2013 .
1266 2006 .
1266 2007 .
1266 2008 .
1266 2009 .
1266 2010 .
1266 2011 1
1266 2012 .
1266 2013 .
end