BookmarkSubscribeRSS Feed
primmer3001
Calcite | Level 5

I have inherited the code but I am not an experienced SAS Coder. I have never seen arrays in any code before. I am getting error when running a section with the MAX and Array loop within it. Please assist. The code is:-

data final_ccf_fca;
set all_data_fca;

array amt_arrs{1:&m.} amt_arrears_1 - amt_arrears_&m.;
array ltr_arrs{1:&m.} amt_ltr_fee_1 - amt_ltr_fee_&m.;
array arrs_bal{1:&m.} arrs_bal_1 - arrs_bal_&m.;
array arrs_bal_inc{1:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
array arrs_inst{1:&m.} arrs_inst_2 - arrs_inst_&m.;

do i=1 to &m.;
arrs_bal{i} = amt_arrs{i} - ltr_arrs{i};
j=i-1;
if i>1 then do;
arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
arrs_inst{i} = arrs_bal_inc{i} / amt_inst;
end;
end;

max_value = max(of arrs_inst{*});

if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;

run;

 

With the error message:-

35932 data final_ccf_fca;
35933 set all_data_fca;
35934
35935 array amt_arrs{1:&m.} amt_arrears_1 - amt_arrears_&m.;
35936 array ltr_arrs{1:&m.} amt_ltr_fee_1 - amt_ltr_fee_&m.;
35937 array arrs_bal{1:&m.} arrs_bal_1 - arrs_bal_&m.;
35938 array arrs_bal_inc{1:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
ERROR: Too few variables defined for the dimension(s) specified for the array arrs_bal_inc.
35939 array arrs_inst{1:&m.} arrs_inst_2 - arrs_inst_&m.;
ERROR: Too few variables defined for the dimension(s) specified for the array arrs_inst.
35940
35941 do i=1 to &m.;
35942 arrs_bal{i} = amt_arrs{i} - ltr_arrs{i};
35943 j=i-1;
35944 if i>1 then do;
35945 arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
35946 arrs_inst{i} = arrs_bal_inc{i} / amt_inst;
35947 end;
35948 end;
35949
35950 max_value = max(of arrs_inst{*});
---
71
ERROR 71-185: The MAX function call does not have enough arguments.

35951
35952 if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;
35953
35954 run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
35946:24
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FINAL_CCF_FCA may be incomplete. When this step was stopped there were 0 observations and 12 variables.
WARNING: Data set WORK.FINAL_CCF_FCA was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

16 REPLIES 16
PaigeMiller
Diamond | Level 26

The problem may be that your code has not produced a value for &M, or the value of &M is not valid for arrays.

 

Please add this line at the top of your code (immediately above data final_ccf_fca;) and run it again, and show us the log.

%put &=M;

 

--
Paige Miller
primmer3001
Calcite | Level 5
The Value for &m. is 2. That is defined further up in the code.
Kurt_Bremser
Super User

In a SAS log, the last ERROR message is always the least important. Start debugging from the top down.

In your case, the crucial problem lies here:

35938 array arrs_bal_inc{1:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
ERROR: Too few variables defined for the dimension(s) specified for the array arrs_bal_inc.
35939 array arrs_inst{1:&m.} arrs_inst_2 - arrs_inst_&m.;
ERROR: Too few variables defined for the dimension(s) specified for the array arrs_inst.

Suppose that macro variable &m contains a value of 5, then the code translates to this after the macro variable is resolved:

array arrs_bal_inc{1:5} arrs_bal_inc_2 - arrs_bal_inc_5;

Since the variable list expands to only 4 members (arrs_bal_inc_2, arrs_bal_inc_3, arrs_bal_inc_4, arrs_bal_inc_5), but the dimension requires 5 elements, you get the ERROR. Either adapt the dimension or the variable list, but this depends on what the code should do.

My suspicion is that the last two array definitions should be

array arrs_bal_inc{2:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
array arrs_inst{2:&m.} arrs_inst_2 - arrs_inst_&m.;
primmer3001
Calcite | Level 5
Thanks KurtBremser. I amended the code as you suggested and now get the below message:-
36111
36112 max_value = max(of arrs_inst{*});
---
71
ERROR 71-185: The MAX function call does not have enough arguments.

Kurt_Bremser
Super User

Did you read the WHOLE log?

Because this works:

data all_data_fca;
input amt_arrears_1 amt_arrears_2 amt_ltr_fee_1 amt_ltr_fee_2 amt_inst;
datalines;
1 2 3 4 5
;

%let m=2;

data final_ccf_fca;
set all_data_fca;
array amt_arrs{1:&m.} amt_arrears_1 - amt_arrears_&m.;
array ltr_arrs{1:&m.} amt_ltr_fee_1 - amt_ltr_fee_&m.;
array arrs_bal{1:&m.} arrs_bal_1 - arrs_bal_&m.;
array arrs_bal_inc{2:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
array arrs_inst{2:&m.} arrs_inst_2 - arrs_inst_&m.;
do i = 1 to &m.;
  arrs_bal{i} = amt_arrs{i} - ltr_arrs{i};
  j = i - 1;
  if i > 1 then do;
    arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
    arrs_inst{i} = arrs_bal_inc{i} / amt_inst;
  end;
end;
max_value = max(of arrs_inst{*});
if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;
run;

Log:

 81         data final_ccf_fca;
 82         set all_data_fca;
 83         array amt_arrs{1:&m.} amt_arrears_1 - amt_arrears_&m.;
 84         array ltr_arrs{1:&m.} amt_ltr_fee_1 - amt_ltr_fee_&m.;
 85         array arrs_bal{1:&m.} arrs_bal_1 - arrs_bal_&m.;
 86         array arrs_bal_inc{2:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
 87         array arrs_inst{2:&m.} arrs_inst_2 - arrs_inst_&m.;
 88         do i = 1 to &m.;
 89           arrs_bal{i} = amt_arrs{i} - ltr_arrs{i};
 90           j = i - 1;
 91           if i > 1 then do;
 92             arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
 93             arrs_inst{i} = arrs_bal_inc{i} / amt_inst;
 94           end;
 95         end;
 96         max_value = max(of arrs_inst{*});
 97         if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;
 98         run;
 
 NOTE: There were 1 observations read from the data set WORK.ALL_DATA_FCA.
 NOTE: The data set WORK.FINAL_CCF_FCA has 1 observations and 13 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.01 seconds
primmer3001
Calcite | Level 5
This is my log from running the code :

NOTE: Remote submit to SASSRV commencing.
36365 data final_ccf_fca;
36366 set all_data_fca;
36367 array amt_arrs{1:&m.} amt_arrears_1 - amt_arrears_&m.;
36368 array ltr_arrs{1:&m.} amt_ltr_fee_1 - amt_ltr_fee_&m.;
36369 array arrs_bal{1:&m.} arrs_bal_1 - arrs_bal_&m.;
36370 array arrs_bal_inc{2:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
36371 array arrs_inst{2:&m.} arrs_inst_2 - arrs_inst_&m.;
36372 do i = 1 to &m.;
36373 arrs_bal{i} = amt_arrs{i} - ltr_arrs{i};
36374 j = i - 1;
36375 if i > 1 then do;
36376 arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
36377 arrs_inst{i} = arrs_bal_inc{i} / amt_inst;
36378 end;
36379 end;
36380 max_value = max(of arrs_inst{*});
---
71
ERROR 71-185: The MAX function call does not have enough arguments.

36381 if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;
36382 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FINAL_CCF_FCA may be incomplete. When this step was stopped there were 0 observations and 14 variables.
WARNING: Data set WORK.FINAL_CCF_FCA was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


NOTE: Remote submit to SASSRV complete.
Tom
Super User Tom
Super User
What version of SAS are you running? I cannot get the MAX() function to generate that error message.
Tom
Super User Tom
Super User

I can get that error using an empty variable list, but not with an ARRAY reference.  Perhaps older versions of SAS generate it with only one variable?

If you can add another input to the max function to make sure there are at least one (two) inputs then the error will not occur.

max(.,of array_name[*])

Example log from SAS 9.2 showing that it does generate an error when using only one variable with MAX(). Adding the extract missing value in the call will make it works since now there are at least two arguments.

8    data test;
9      x=1;
10     max=max(of x);
           ---
           71
ERROR 71-185: The MAX function call does not have enough arguments.

11     max=max(.,of x);
12   run;

 

primmer3001
Calcite | Level 5

I'm using SAS 9.2

Tom
Super User Tom
Super User
That version is 10 years old. You are paying SAS. You can update your version.
Kurt_Bremser
Super User

@primmer3001 wrote:

I'm using SAS 9.2


Upgrade. NOW. Most of the software you get from others (and all the hints you get here on the Communities) is created with the current version.

primmer3001
Calcite | Level 5
I use SAS through work. They are currently in the process of moving to SAS Studio. I have a similar piece of cod ethat does work, but this one doesn't. Below is the other piece of inherited code but DOES work:-

data final;
set cfs_instal_fca;

%let prev_m = %sysevalf(&m.-1);

array arrs_bal{0:&m.} amt_delq_0 - amt_delq_&m.;
array arrs_bal_inc{1:&m.} arrs_bal_inc_1 - arrs_bal_inc_&m.;
array arrs_inst{1:&m.} arrs_inst_1 - arrs_inst_&m.;
array min_pay{0:&prev_m.} amt_last_min_pymt_0 - amt_last_min_pymt_&prev_m.;

do i=1 to &m.; j=i-1;
arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
arrs_inst{i} = arrs_bal_inc{i} / min_pay{j};
end;

max_value=max(of arrs_inst{*});

if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;

run;
primmer3001
Calcite | Level 5

Hi KurtBremser. I have just ran your code and get the below:

 


1 data all_data_fca;
2 input amt_arrears_1 amt_arrears_2 amt_ltr_fee_1 amt_ltr_fee_2 amt_inst;
3 datalines;

NOTE: The data set WORK.ALL_DATA_FCA has 1 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


5 ;
6
7 %let m=2;
8
9 data final_ccf_fca;
10 set all_data_fca;
11 array amt_arrs{1:&m.} amt_arrears_1 - amt_arrears_&m.;
12 array ltr_arrs{1:&m.} amt_ltr_fee_1 - amt_ltr_fee_&m.;
13 array arrs_bal{1:&m.} arrs_bal_1 - arrs_bal_&m.;
14 array arrs_bal_inc{2:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
15 array arrs_inst{2:&m.} arrs_inst_2 - arrs_inst_&m.;
16 do i = 1 to &m.;
17 arrs_bal{i} = amt_arrs{i} - ltr_arrs{i};
18 j = i - 1;
19 if i > 1 then do;
20 arrs_bal_inc{i} = arrs_bal{i} - arrs_bal{j};
21 arrs_inst{i} = arrs_bal_inc{i} / amt_inst;
22 end;
23 end;
24 max_value = max(of arrs_inst{*});
---
71
ERROR 71-185: The MAX function call does not have enough arguments.

25 if round(max_value,0.00001)>=1 then whole_payment=1; else whole_payment=0;
26 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FINAL_CCF_FCA may be incomplete. When this step was stopped there
were 0 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds

 

PeterClemmensen
Tourmaline | Level 20

If &m. does have a value, then your problem is probably that you specify m-1 variables in your array in the lines below.

 

array arrs_bal_inc{1:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
array arrs_inst{1:&m.} arrs_inst_2 - arrs_inst_&m.;

You should either specify m variables like this

 

array arrs_bal_inc{1:&m.} arrs_bal_inc_1 - arrs_bal_inc_&m.;
array arrs_inst{1:&m.} arrs_inst_1 - arrs_inst_&m.;

 

or specify m-1 entries in your array like this

 

array arrs_bal_inc{2:&m.} arrs_bal_inc_2 - arrs_bal_inc_&m.;
array arrs_inst{2:&m.} arrs_inst_2 - arrs_inst_&m.;

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 16 replies
  • 2045 views
  • 2 likes
  • 6 in conversation