If no conditions are involved the simplest way would be to include a retain statement:
data want;
merge have1(in=a) have2;
by ID;
retain flag 1;
if a;
run;
Missed SAS Innovate in Orlando?
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.