compress(var2,'', 'A')
The COMPRESS function produces a character string, in this case a character string of the letters in VAR2. For the first row of your data set you get the character string '01'. It is not a number, even if it looks like a number to you, so SAS does not know how to evaluate if the character string '01' is greater than &range_1, which is a number. SAS cannot compare characters strings to numbers. So to fix this, you want to convert the character string from var2 into an actual number. You do this by
input(compress(var2,'', 'A'),3.)
which turns the character string into the actual number 1. Then it can be compared to the number in &range_1. This will handle numbers up to 3 digits wide (i.e <= 999).
My macro variables are defined as:
%let range_1 = 13; %let range_2 = 24;
so they appear to be numeric so I'm not sure where my error might be?
The values of macro variables are always text, no matter that they look like numbers. The only way they become numbers is if you use them in a way that SAS recognizes them as numbers. In this case, when SAS evaluates the code, it replaces &range_1 with 13, and so then the code actually becomes
compress(var2,'', 'A') > 13
and then SAS recognizes 13 as a number from the context. Do you know why in the above line that 13 is treated as a number and not a character string?
@Jeff_DOC you're not new here. Please be a good citizen of the community and help us just as we are trying to help you. When you get errors in the log, then SHOW US THE LOG. We need to see the entire log for the DATA step (or PROC) that has the error from now on, without having ask.
... View more