BookmarkSubscribeRSS Feed
iSAS
Quartz | Level 8

My program works fine when the dataset did not come from SAS Viya. However, if it came from viya, i receive this error:

 

ERROR: Array subscript out of range at line 52 column 3.

 

Below is the program. It throws an error the moment I add statuses(schedule_id) = return_cd1 and date_stat(schedule_id) = LOG_END_DTTM:

 

%macro arrange;
%do i=1 %to %trim(&cnt.);
/*In order for data step Job_Sch_Merge2 logic to work correctly, each _n_TH iteration should be placed at the bottom. */

data want want&i;
set Today_progress;
if &i=obs then output want&i; /*Every _n_=i will be added to want&i*/
else output want;
run;

data Job_Sch_Merge2;
set want want&i; /*This will make the _n_TH iteration be placed at the bottom*/

array statuses(1000) _temporary_;
array date_stat(1000) _temporary_;

length pending_job $100;

statuses(schedule_id) = return_cd1;
date_stat(schedule_id) = LOG_END_DTTM;
run;


%end;
%mend;

%arrange;

3 REPLIES 3
Kurt_Bremser
Super User

Your macro is unnecessary, as the resulting dataset will contain the result from the last %DO loop iteration in any case, so it is sufficient to do the whole process once with the value of &cnt.

 

Anyway, you have at least one value in schedule_id that falls outside of the range 1:1000. You can see in the log which value this is.

iSAS
Quartz | Level 8

But how come my datasets created in non SAS Viya that is totally the same (parameters, values, and observation) with the dataset created in SAS Viya doesn't fail?

 

This is also the sample of the log:

ERROR: Array subscript out of range at line 61 column 50.
LOG_END_DTTM=02DEC2020:16:35:17 SCHEDULE_ID=1200 return_cd1=1 obs=. pending_job= _ERROR_=1 _N_=1

 

Those values don't fail if the datasets don't come in non-SAS Viya

Kurt_Bremser
Super User

An array with a maximum index of 1000 CANNOT work with an index of 1200, PERIOD.

Run

proc sql;
select min(schedule_id) as min_sched, max(schedule_id) as max_sched
from dataset;
quit;

for both datasets. You should also use PROC COMPARE before claiming that datasets are identical.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 866 views
  • 0 likes
  • 2 in conversation