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
There are too many observations in your dataset. What do you want to do with the macro variable?
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.
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
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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.