Adjus next code to the required number of decimal places:
data fees;
infile datalines truncover;
informat accountid 3.reportdate date9. old_interest_amt 5.2
balance 4. total_fees best4.;
input accountid ReportDate Old_Interest_Amt Balance Total_Fees;
format reportdate date9. old_interest_amt 5.2;
datalines;
123 07Mar2022 34.63 2282 39
123 07Apr2022 18.53 2281 78
456 11May2022 25.7 1337 44
456 10Jun2022 26.94 1411 88
456 11Jul2022 11.21 1464 132
; run;
Data want;
set fees;
by AccountID;
retain lag_diff;
if first.AccountID then do;
lag_diff=0;
New_Balance = Balance - Total_Fees;
New_Int_Amt = (0.099 * New_Balance)/12;
Diff = Old_Interest_Amt - New_Int_Amt;
end;
else do;
New_Balance = Balance - lag_diff - Total_Fees;
New_Int_Amt = (0.099 * New_Balance)/12;
Diff = Old_Interest_Amt - New_Int_Amt;
end; output;
lag_diff = diff;
format New_Balance 4. lag_diff New_Int_Amt Diff 5.2
run;
... View more