DATA Step, Macro, Functions and more

Length of the value of the macro variable error (65534).

Reply
New Contributor
Posts: 2

Length of the value of the macro variable error (65534).

Hi All,

I am new to SAS Macros, any help would be appreciated. 

I am creating a ID which is basically a combination of different variables, and then trying to call the distinct ids inside my macro.

When I try to exceute the macro, I get the below mentioned error

 

ERROR: The length of the value of the macro variable DT1 (65540) exceeds the maximum length (65534). The value has been truncated
to 65534 characters.

 

Can someone please help me resolve this error?

 

PFB the code I have written.

 

data test1;

set test2;

id1 = trim("_"||catx("_",put(minDate, date9.), put(maxDate, date9.), Sales_id ,Division, Roll_Up));

run;

 

proc sql;
select distinct id1 into: dt1 separated by " " from test`;

%macro dly_mlt_lock;

...........

%mend

 

TIA

Super User
Posts: 6,962

Re: Length of the value of the macro variable error (65534).

There are too many observations in your dataset. What do you want to do with the macro variable?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 2

Re: Length of the value of the macro variable error (65534).

[ Edited ]

Hello Kurt!

 

Thanks for the reply.

 

Based on these variables, I am creating a counter in my macro which will produce the output based on these multiple combinations. 

 

Is there any other way where I can create a key which would be a combination of  multiple variable apart from the way I have created them in my earlier post?

 

Since i am new to macro I am unable to understand what exactly is the problem. Kindly help me resolve this issue.

PROC Star
Posts: 7,363

Re: Length of the value of the macro variable error (65534).

How many records are in the file that you are creating the id for? Also, what are the lengths of the various fields that are being concatenated to form the id?

 

Are there other methods? Yes! The hash object and creating formats come immediately to mind, but one would have to know the answers to the questions I asked above.

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 17,886

Re: Length of the value of the macro variable error (65534).

The error is

 

ERROR: The length of the value of the macro variable DT1 (65540) exceeds the maximum length (65534). The value has been truncated to 65534 characters.

 

So, the error is that the macro variable being created is too long means you need a shorter macro variable. 

 

You could:

1. Create several macro variables

2. Refactor your code to not require macro variables. Macro's are useful, but there are many ways to do things without them in SAS, and learning those first is a better place to start. 

 

If you explain what you're trying to do in more detail, some one can suggest alternative solutions.  To determine all 'unique combinations' is a bit vague. Is this across observations or just along a single row. It's really rare to concatenate all variables and then create all combinations. And why not use CALL LEXCOMB/ALLCOMB instead if it is a permutation problem. 

Super User
Posts: 6,962

Re: Length of the value of the macro variable error (65534).

If you have lots of parameters for repeatedly running/creating code, store them in a dataset and use call execute to create the code.

For further help, we need to know the code that is to be parametrized.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 221 views
  • 0 likes
  • 4 in conversation