With the same requirements as for @ballardw's solution you could use a DO-UNTIL loop:
data want;
do until(last.A);
set have;
by A B notsorted;
if ~flag then output;
if B='b' & last.B then flag=1;
end;
drop flag;
run;
For background information about this special usage of the DO-UNTIL loop ("DOW loop"), please see, for example, http://www2.sas.com/proceedings/sugi28/099-28.pdf.
... View more