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;
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.
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
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.