Hi @dapenDaniel
data have;
input FirmID Year indicator;
cards;
10001 1995 1
10001 1996 0
10001 1997 0
10001 1997 1
10001 1998 1
10001 1999 0
10001 1999 0
10001 1999 1
10001 2000 0
10001 2001 1
;
proc sql;
create table want as
select firmid, year, sum(indicator=0) as nb_Indicator_0
from have
group by firmid, year;
quit;
/*or*/
data want;
do until(last.year);
set have;
by FirmID Year;
nb_Indicator_0=sum(indicator=0,nb_Indicator_0);
end;
drop indicator;
run;