Hello @DavidsM,
You're welcome. I'm happy that I could help you.
The solution disregarding the extra rule about the last event is exactly that in my earlier post. To check this assertion, you can compare the result of that shorter data step (using a large input dataset HAVE) with the result of the extended data step, but with one line commented out (and, of course, a different output dataset name, e.g. WANT0):
*if date=evdate_last & event then new_event=1;
PROC COMPARE should then confirm the equality of WANT and WANT0.
Please note that the shorter data step is more efficient than the extended one because for the extra rule (whether applied or not, i.e. with the above IF/THEN statement active or commented out) I used a second SET statement, i.e., dataset HAVE is read twice.