AML scenario code

![CODE FOR CALCULATING SUM IN AML][1]
i am handling aml scenario development in transaction monitoring. i am calculating sum of currency amount for last 10 days.

problem is, we have only 10 days of data between 10march2018 to 19march2018.
it did not give output when i have given rundate as 30 march, but it is giving output in other conditions and loop should run 10 day only.

if any wrong in that code and calculation please send me proper code and

thoughts.
sa

data sample data;
infile cards;
input   party_number10.  currency_amount10. date_key date9.;
cards;
1  2000  10mar2018
1  1000  10mar2018
2  2000  10mar2018
2  10000 10mar2018
1  2000  11mar2018
2  1000  12mar2018
1  2000  13mar2018
2  1000  13mar2018
1  2000  14mar2018
2  1000  15mar2018
;
expecting sum of currency amount on each party_num  wise in 10days like
party_number  Total
1              9000
2               13000
   enter code here

 %let this_macro_name = &sysmacroname; 
%let  p113_period_days=10;/*parameter in aml front*/
%let  agg_amount =100000;/*parameter in aml front*/
p113_I_begin_date = input(put(rundate_number-&p113_period_days+1,num_to_date.),8.);

do i = n to 1 by -1 while (date_key{i} >= p113_I_begin_date);
if p113_I_begin_date <= date_key{i} <= rundate then do;
if upcase(transaction_cdi_code{i}) in (&p113_cdi_indicator) and
upcase(primary_medium_desc{i}) in (&p113_pri_medium_desc) then do;
%fcf_save_transaction_key(calling_macro=&this_macro_name);
p113_total_amount = sum(p113_total_amount,currency_amount{i});

    end;
    end;
    end;
if p113_total_amount>=&agg_amount then do;
actual_values_text  =  tranwrd(&r10007_threshold_message,'#1',kstrip(put(p113_total_amount,nlnum32.)) );
    output &alert_fname;
end; 

AML scenario code