I've found this is real easy once you stop trying to be elegant, and just use two data steps.
Alternatively, if you already have a dataset with exclusions that are more complicated than just service="reading", you can make the eliminates dataset likeCode:
*Identify the teacher/date records to eliminate: associated with reading; data eliminates; set yourdata; if upcase(service)="READING"; keep teacher student date; run; *Reduce YOURDATA set; proc sort data=yourdata; by teacher student date; run; proc sort data=eliminates nodupkey; by teacher student date; run; data yournewdata; merge yourdata(in=a) eliminates(in=b); by teacher student date; if (not b); run;
I've done stuff like this before using retain statements, delete flags, and sorting...but it's really simple like this.Code:
data eliminates; merge yourdata(in=a) exclusions(in=b); by service; if a and b; keep teacher student date; run;