03-25-2017 05:49 PM
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.
id1 = trim("_"||catx("_",put(minDate, date9.), put(maxDate, date9.), Sales_id ,Division, Roll_Up));
select distinct id1 into: dt1 separated by " " from test`;
03-25-2017 06:03 PM
There are too many observations in your dataset. What do you want to do with the macro variable?
03-25-2017 06:13 PM - edited 03-25-2017 06:17 PM
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.
03-25-2017 08:18 PM
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
03-25-2017 09:30 PM
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.
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.
03-26-2017 04:24 AM
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.