You need to have the data sorted in the order you want it, and exclude the data you don't want. If your data is already sorted, put the where clause on the set statement. To save time/space, only keep the variables you need. (I'm not sure if you need to keep seq after the data is sorted, for example.) proc sort data=have(keep=num1 num2 seq class cost time ID where=(cost=0)) out=haveSorted(drop=cost seq); by num1 num2 seq; run; data want; set haveSorted; by num1 num2; if last.num2 then output; run;
... View more