If you put the sort and second data step inside a code node in EG this should work
data have;
infile datalines dlm=",";
input date mmddyy8. CustomerAccount InterestRate;
format date ddmmyy10.;
datalines;
1/1/2016,1,2
2/1/2016,1,2
3/1/2016,1,3
4/1/2016,1,3
1/1/2016,2,8
2/1/2016,2,8
3/1/2016,2,9
4/1/2016,2,9
;
run;
proc sort data=have out=sorted;
by CustomerAccount date;
run;
data want(keep= date CustomerAccount PreviousRate NewRate);
set sorted;
by CustomerAccount;
PreviousRate=lag(InterestRate);
if not first.CustomerAccount then do;
if PreviousRate ne InterestRate then do;
NewRate=InterestRate;
output;
end;
end;
run;
... View more