Hi everyone,

I have a dataset including over 500 firms that have CEO changes based on CEO_ID and lagged CEO_ID. Please see the following table to understand my dataset. I want to create an indicator variable that is equal to one for one year after the CEO changes and zero for one year before the CEO changes. Could you give me some suggestions on how I can create that indicator variable in this case? Thanks in advance for your help.
gvkey fyear execid execid_n lag1_execid CEO_change
1004 2003 9251 9251 9252 -1
1004 2004 9252 9252 9251 1
1004 2005 23781 23781 9252 14529
1004 2006 9249 9249 23781 -14532
1004 2008 23781 23781 9249 14532
1004 2009 36199 36199 23781 12418
1004 2010 9249 9249 36199 -26950
1004 2011 41787 41787 9249 32538
1004 2012 33979 33979 41787 -7808
1004 2013 46404 46404 33979 12425
1004 2015 9249 9249 46404 -37155
1004 2016 51706 51706 9249 42457
1045 2002 3661 3661 3662 -1
1045 2004 16654 16654 3661 12993
1045 2007 28280 28280 16654 11626
1045 2008 14591 14591 28280 -13689
1045 2009 28280 28280 14591 13689
1045 2011 14591 14591 28280 -13689
1045 2015 46190 46190 46189 1
1045 2016 46193 46193 46190 3
1075 2004 19092 19092 10739 8353
1075 2005 10739 10739 19092 -8353
1075 2009 39817 39817 10739 29078
1075 2010 33218 33218 39817 -6599
1075 2011 12755 12755 33218 -20463
1075 2012 5835 5835 12755 -6920
1075 2013 39817 39817 5835 33982
1075 2014 12755 12755 39817 -27062
1078 2003 18569 18569 20862 -2293
1078 2004 20862 20862 18569 2293
1078 2005 24400 24400 20862 3538
1078 2006 14300 14300 24400 -10100