Assume that each company only appear once each year, and in the following, even try to make your data a little more complex (there are gaps between years)
clear
input year str20 comp
2001 "Bank of America"
2001 "General Motors"
2001 "General Elec"
2002 "General Motors"
2002 "General Elec"
2003 "Goldman Sachs"
2003 "General Elec"
2008 "General Motors"
2009 "Goldman Sachs"
end
bysort comp (year): gen num=year[_n]-year[_n-1]
replace num=0 if num>1