clear
input firm ceo start end
1 1 2002 2012
1 2 2005 2010
1 3 2005 2008
2 4 2000 2002
2 5 2008 2012
end
forval x=2002/2012 {
gen tenure`x'=0
}
forval x=2002/2012 {
replace tenure`x'=1 if start==`x' | end == `x' | (start< `x' & end >`x')
}
drop start end
sort firm ceo
reshape long tenure, i(firm ceo) j(year)
l