hi everybody,
Can someone kindly suggest me why does the following snippet work in its first part and doesn't in its second?
I'm going crazy. Thank you in advance for your appreciated help.
Marco
ps. Sas version: 9.4
*****
data try;
array hkey (0 : 5128933102) _temporary_ ;
*this part works;
hkey(5128077630)=5;
put hkey(5128077630)=;
*this part doesn't work (ERROR: Array subscript out of range);
i=5128077630;
hkey(i)=5;
put hkey(i)=;
run;
Are you sure it works.
I suspect you do not have enough memory to make an array with over 5 BILLION variables in it.
Try running this example. I'm going with 101 array elements since +5B i quite memory heavy. Seems to work fine?
Can you post the full log for your original run?
data try;
array hkey (0 : 100) _temporary_ ;
hkey(100)=5;
put hkey(100)=;
i=100;
hkey(i)=100;
put hkey(i)=;
run;
See how large an array you can make on your system.
%macro test;
%do i=1 %to 10 ;
%let upper=%sysevalf(10**&i);
%let syscc=0;
data try;
array hkey (0 : &upper) _temporary_ ;
run;
%put &=i &=syscc &=upper;
%end;
%mend;
%test;
Post the logs of both tests. I seriously doubt you can establish an array that eats 40 GB of RAM.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.