Dear Members,
I try to identify firms (id) in a panel data with 'status' == 1 for at least 3 years in a row and then code these years as 1, zero otherwise. Please help me with this.
My data set looks like below. Many thanks. Lynn.
I try to identify firms (id) in a panel data with 'status' == 1 for at least 3 years in a row and then code these years as 1, zero otherwise. Please help me with this.
My data set looks like below. Many thanks. Lynn.
Code:
clear input float(id year status) 1 2003 1 1 2004 1 1 2005 0 1 2006 1 1 2007 1 1 2008 1 1 2009 0 1 2010 1 1 2011 1 1 2012 1 1 2013 1 1 2014 0 1 2015 0 1 2016 0 1 2017 0 1 2018 0 1 2019 0 1 2020 0 1 2021 0 2 2002 0 2 2003 0 2 2004 1 2 2005 0 2 2006 1 2 2007 0 2 2008 1 2 2009 1 2 2010 1 2 2011 0 2 2012 0 2 2013 0 2 2014 0 2 2015 0 3 2011 1 3 2012 1 4 2015 0 5 2017 1 5 2019 1 5 2020 0 5 2021 1 end
Comment