At first glance, this looks rather straightforward, however, after discovering the question could involve both sequencing and no-sequencing process, It seems that Hash object is to be utilized to deliver a more robust solution.
data have;
input person date : $20. product $ paid : dollar.;
cards;
1 1/25/15 apple $50
1 1/25/15 apple $43
1 1/25/15 apple $-43
2 1/30/15 orange $50
3 1/31/15 apple $55
;
data want;
if _n_=1 then do;
if 0 then set have;
declare hash h(dataset:'have(rename=(paid=_p) where=(_p<0))', multidata:'y');
h.definekey('person','date','product');
h.definedata(all:'y');
h.definedone();
call missing (_p);
end;
set have (where=(paid>=0));
_rc=h.find();
if paid eq -1*_p then do;
_rc=h.removedup();
delete;
end;
drop _:;
run;
... View more