BookmarkSubscribeRSS Feed
RichardDeVen
Barite | Level 11

I run code in a SAS Server that give the session 4GB of RAM (MEMSIZE=4,294,967,296).

 

A program is being developed that will act on a data set many times and the SASFILE statement is being used to speed up the repeated uses of the data.

 

SASFILE LIB.XYZ OPEN

 

The problem is that sometimes the data set is larger than 4GB.

 

Is there a reliable way to test if SASFILE will fail?   

 

 

 

In exploring this question I made a sandbox session with far less memory (128MB) to see logging and macro variables in low memory situations

C:\Program Files\SASHome\SASFoundation\9.4\sas.exe -sasuser c:\temp\sasuser -memsize 128MB

and this program to create an outsized data set for the session and attempt to SASFILE it

data x;
  set sashelp.cars;
  do _n_ = 1 to 2500;
    output;
  end;
run;

sasfile work.x open;
%put _all_;
sasfile work.x close;

A first run of the code logs an out of memory

8    sasfile work.x open;
WARNING: Out of memory.
9    %put &=SYSWARNINGTEXT;
SYSWARNINGTEXT=Out of memory.
10   %put &=SYSERRORTEXT;
SYSERRORTEXT=
11   sasfile work.x close;
NOTE: The file WORK.X.DATA has been closed by the SASFILE statement.

The SYSWARNINGTEXT is just about the only useful info, however, there is no way to reset the warning text for later tests

If the warning goes unheeded and a DATA step involving the oversized file the system fails the step and limps along in a state I would not trust, such as continued steps can't continue because the LOG window is clogged (The LOG window must grab a fair amount of.RAM for itself)

 

 

 

 

 

 

4 REPLIES 4
Oligolas
Barite | Level 11

Hi,

 

none I know of, but a workaround could be to estimate the dataset size before a memory load?

________________________

- Cheers -

andreas_lds
Jade | Level 19

sashelp.vtable has the size of all datasets available in the session. Try:

 

data _null_;
   set sashelp.vtable;
   where libname = 'LIB' and memname = 'XYZ';
   memsize = input(getOption('memsize'), best.);
   
   if filesize < memsize then do;
      call execute('sasfile lib.xyz open;');
   end;
run;
Oligolas
Barite | Level 11

N1ce that should do the trick 😊

________________________

- Cheers -

Quentin
Super User

It's hack, but while you can't write to SYSWARNINGTEXT, if you write a WARNING: note to the log, looks like SAS will update the value:

 

1    %put WARNING: Out of memory ;
WARNING: Out of memory
2    %put &=syswarningtext ;
SYSWARNINGTEXT=Out of memory
3
4    %put WARNING: %str( ) ;
WARNING:
5    %put &=syswarningtext ;
SYSWARNINGTEXT=

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
  • 4 replies
  • 1429 views
  • 2 likes
  • 4 in conversation