12-11-2013 11:36 AM
I have a macro that checks many conditions such as these ones:
%IF %STR(&LEADER) NE %STR() %THEN %DO;
%IF %SYSFUNC(FILEEXIST(&PATH.\&SUPERVISOR.\&LEADER.)) %THEN %DO;
In the above, two of the arguments (SUPERVISOR and LEADER) can sometimes have hypens because they are names. When this happens, it yields the following error:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: &LEADER NE
Is there any way around this or should I instruct users to remove hyphens when they call the macro?
Thank you in advance for your help and suggestions,
12-11-2013 11:53 AM
An easy way for &LEADER would be:
%if %length(&leader) > 0 %then %do;
This could actually be abbreviated to:
%if %length(&leader) %then %do;
Are you sure that &SUPERVISOR is actually causing a problem? It looks like it should be OK.
12-11-2013 12:39 PM
A better way to check to see if a macro variable &leader is blank is:
This eliminates all possible problems caused by hyphens and other special characters
Need further help from the community? Please ask a new question.