BookmarkSubscribeRSS Feed
ubange
Calcite | Level 5

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;

4 REPLIES 4
Tom
Super User Tom
Super User

Are you sure it works.

I suspect you do not have enough memory to make an array with over 5 BILLION variables in it.

 

PeterClemmensen
Tourmaline | Level 20

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;
Tom
Super User Tom
Super User

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;

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 416 views
  • 0 likes
  • 4 in conversation