Help using Base SAS procedures

How big a SAS macro variable can take?

Reply
Regular Contributor
Posts: 201

How big a SAS macro variable can take?

I want use sas sql to crate a new macro:

 

 proc sql;

select xyz into  : abc separated by ',' from large_data;

quit;

 

to create a new macro variable,,if dataset large_data has very large observations .   I am not sure how the new macro &abc can load it. and is there any option to modify the macro size to load a large size value?

 

Thanks

Respected Advisor
Posts: 3,124

Re: How big a SAS macro variable can take?

Nope. The max length of a macro variable is 65534 chars.

 

Very often when you encounter something like this (system limit), there are better alternatives, some even without involving macro variables. Please explain your whole picture.

Super User
Posts: 10,466

Re: How big a SAS macro variable can take?

[ Edited ]

The system option MVARSIZE controls the size limit of a single macro variable and allows assigning some pretty large values

You can change it using an option statement

 

options mvarsize=32000; would set the max size to 32000 bytes

options mvarsize-32000K; would set the max size to 32000 kilobytes.

Use M for megabyts and G for Gigabytes. The maximun number allowed in the assignement is 65534.

 

HOWEVER you have to pay attention to the maximum total amount of memory assigned to all macro variables which is similary controlled by the MSYMTABMAX option setting. If you use most of the memory for a single macro variable you may not be able to assign other macro variables within memory and the system will start spending a lot of time writing macro values to disk and then rereading.

 

But as @Haikuo mentions there are often better ways to handle things when you start bumping up against memory limits for macros.

Respected Advisor
Posts: 3,124

Re: How big a SAS macro variable can take?

@ballardw ,

 

One thing learned.

 

Thanks!

Haikuo

Super User
Posts: 10,466

Re: How big a SAS macro variable can take?


Haikuo wrote:

@ballardw ,

 

One thing learned.

 

Thanks!

Haikuo


I've been programming in SAS off and on for almost 30 years. I have never had to actually use the MVARSIZE and related options.

PROC Star
Posts: 1,555

Re: How big a SAS macro variable can take?

[ Edited ]

@ballardw

 

MVARSIZE set the maximum in-memory size. The default is 4k. The maximum size for macro variables is still 64k sadly.

Ask a Question
Discussion stats
  • 5 replies
  • 283 views
  • 0 likes
  • 4 in conversation