If you want to go down the SAS route, it reads data sequentially so is very good at this type of problem
data have;
infile datalines missover;
input Name $ ID Event $;
datalines;
Smith 1
Smith 2 Y
Smith 3
Jones 1
Jones 2 Y
Jones 3
Jones 4 Y
;
run;
proc sort data=have;
by name id;
run;
data want;
set have;
by name id;
if first.name then event_count=0;
event_count+(event='Y');
run;