If you don't have a big table ,try SQL,otherwise try Hash Table.
data x;
infile cards expandtabs;
input FirmID Year Var1 $;
cards;
1001 1995 AA
1001 1995 AB
1001 1995 AC
1001 1995 AD
1001 1996 AA
1001 1996 CS
1001 1996 SW
1001 1997 AC
1001 1997 FD
1001 1998 OL
1001 1999 AD
1001 1999 SC
1001 1999 QW
;
proc sql;
select *
from x as a
where not exists(
select * from x
where FirmID=a.FirmID and
year between a.year-3 and a.year-1 and
Var1=a.Var1);
quit;