OK, I think I get it. Being a team is starting together at the same firm (but it is not their first job) after being previously employed at a (different) same firm. So I think this will do it:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear* input long(gvkey1 execid2) double year 1004 33979 2007 1004 33979 2008 1004 33979 2009 1004 33979 2010 1004 33979 2011 1004 33979 2012 1004 46404 2009 1004 46404 2010 1004 46404 2011 1045 46192 2012 1056 1891 2006 1056 1891 2007 1056 1891 2008 1056 12755 2008 1056 12755 2009 1056 12755 2010 1056 13000 2008 1056 13000 2009 1056 13000 2010 1056 13000 2011 1080 12755 2011 1080 12755 2012 1080 12755 2013 1080 13000 2012 1080 13000 2013 1080 13000 2014 1100 33979 2013 1100 33979 2014 1100 33979 2015 1100 33979 2016 1100 33979 2017 1100 33979 2018 1100 46404 2013 1100 46404 2014 1100 46404 2015 1100 46192 2016 1111 22978 2006 1111 22978 2007 1111 22978 2008 1111 32091 2006 1111 32091 2007 1111 32091 2008 1161 37980 2009 1161 37980 2010 1161 37980 2011 1161 37980 2012 1161 40775 2010 1161 40775 2011 1161 40775 2012 1161 42390 2011 1161 42390 2012 1161 42390 2013 1161 42390 2014 27119 46404 2014 27119 46404 2015 27119 46404 2016 27119 46404 2017 27119 46404 2018 27119 46404 2019 181104 33979 2013 181104 33979 2014 181104 33979 2015 181104 33979 2015 181104 33979 2016 181104 33979 2017 181104 33979 2018 181104 33979 2019 end // CREATE SPELLS OF CONSECUTIVE EMPLOYMENT AT A SINGLE FIRM FOR EACH EXECUTIVE frame put gvkey1 execid2 year, into(working) frame change working by execid2 (gvkey1 year), sort: gen spell = sum(gvkey1 != gvkey1[_n-1] /// | year != year[_n-1] + 1) // CHARACTERIZE EACH SPELL BY ITS START, FINISH, AND ANTECEDENT // AND SUBSEQUENT EMPLOYERS by execid2 spell (year), sort: gen start = year[1] by execid2 spell (year): gen finish = year[_N] by execid2 (spell year): gen previous = gvkey[_n-1] if spell != spell[_n-1] by execid2 (spell year): gen subsequent = gvkey[_n+1] if spell != spell[_n+1] by execid2 spell (year): replace subsequent = subsequent[_N] by execid2 spell (year): keep if _n == 1 drop spell year // NOW IDENTIFY SPELLS THAT HAVE THE SAME EMPLOYER, START, FINISH, // AND ANTECEDENT EMPLOYER FOR MORE THAN ONE EXEC by gvkey1 start previous, sort: keep if _N > 1 & !missing(previous) // RETAIN THE INFORMATION ON PARALLEL TRANSFERS IN FRAME WORKING // AND CREATE A SEPARATE FRAME FOR JUST THE EXECID'S INVOLVED frame put execid2, into(execs_to_drop) frame execs_to_drop: duplicates drop // BACK TO THE ORIGINAL DATA frame change default frlink m:1 execid2, frame(execs_to_drop) drop if !missing(execs_to_drop)
Comment