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
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;
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.;
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
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;
I'm using SAS 9.2
@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.
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
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.;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.