BookmarkSubscribeRSS Feed
anu1989s
Calcite | Level 5

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

5 REPLIES 5
anu1989s
Calcite | Level 5

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.

art297
Opal | Level 21

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

 

Reeza
Super User

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. 

Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 2668 views
  • 0 likes
  • 4 in conversation