Dear reader,
My dataset is a panel dataset with years: 2002-2009 and firms (cusips) and executive id's (execid).
I am trying to create a variable that adopts value 1 when the execid number changes between 2007 and 2009. This means the executive was replaced between those years.
Currently I have the following:
But the problem is that if I have a firm that only has data over 2007 to 2009 the variable also gives a number 1. This is incorrect because this does not mean 1 executive has taken over from antoher.
Does someone know the answer?
Regards,
Nicole
My dataset is a panel dataset with years: 2002-2009 and firms (cusips) and executive id's (execid).
I am trying to create a variable that adopts value 1 when the execid number changes between 2007 and 2009. This means the executive was replaced between those years.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double fyear str12 cusip str6 execid 2002 "001055" "00013" 2003 "001055" "00013" 2004 "001055" "00013" 2005 "001055" "00013" 2006 "001055" "00013" 2007 "001055" "00013" 2008 "001055" "00013" 2009 "001055" "00013" 2004 "004239" "28561" 2005 "004239" "28561" 2006 "004239" "28561" 2007 "004239" "28561" 2008 "004239" "28561" 2009 "004239" "28561" 2002 "00817Y" "20970" 2003 "00817Y" "20970" 2004 "00817Y" "20970" 2005 "00817Y" "20970" 2006 "00817Y" "14660" 2007 "00817Y" "14660" 2008 "00817Y" "14660" 2009 "00817Y" "14660"
Code:
*3.CEO turnover (2007 to 2009 not summed) by execid cusip, sort: gen nvals = _n == 1 if inrange(fyear,2007,2009) count if nvals rename nvals CEOturnover_0709_nosum
Does someone know the answer?
Regards,
Nicole
Comment