data have;
input Nosinid ndep dep;
cards;
1 1 100
1 2 -100
1 3 100
2 1 500
2 2 -500
2 3 500
2 4 -500
2 5 500
2 6 500
3 1 1000
3 2 -500
3 3 500
;
run;
data want(drop=_: flag);
merge have have(firstobs=2 keep=dep Nosinid rename=(dep=_dep Nosinid=_Nosinid));
retain flag 0;
if dep gt 0 and dep+_dep=0 and Nosinid=_Nosinid then do; flag=1;delete; end;
if flag then do;flag=0;delete; end;
run;
Ksharp
... View more