BookmarkSubscribeRSS Feed
MarkGreenaway
Calcite | Level 5

I want to pass two long strings into a sas macro, like this:

%some_macro(first=this is quite a long string, two=and so is this);

I can define macros where I pass an argument like the first, but if I have two arguments like this it seems SAS gets confused, and I get errors about strings being 262 characters or longer. I suspect I should be using some sort of quoting or something, but I'm not sure exactly what to use. Any ideas?

Mark

3 REPLIES 3
art297
Opal | Level 21

Mark,

It would help if you posted an example of code that produces the error.

MarkGreenaway
Calcite | Level 5

%macro

two(first=,second=);

title

"&first &second"

;

proc freq data=hsurvey2.hsa05_adult_public;

table year;

run;

%mend

two;

%two(first=this is a long string, second=and so is this);


It turns out that this works fine. The problem in my code is something else entirely. I'll try to track that down.

Tom
Super User Tom
Super User

There is a limit on the length of a macro variable.  Should be around 32,000.

The error message you report can be suppressed by using the option NOQUOTELENMAX.

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002233891.htm

You would see it if your macro did something like.

data out;

   var1="&first";

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 1265 views
  • 3 likes
  • 3 in conversation