I have the following code segment:
%let alist=a.*;
%let blist=b.*;
%if (&alist=a.*) and (&blist=b.*) %then %do;
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
(&alist=a.*) and (&blist=b.*)
Basically it is the * that caused the error. I would like to compare if alist value equal to a.* and blist value equal to b.*, how to achieve this without error?
Hello,
%macro a;
%let alist=a.*;
%let blist=b.*;
%if (%bquote(&alist)=%str(a.*)) and (%bquote(&blist)=%str(b.*)) %then %do;
%put TRUE;
%end;
%mend a;
%a
One way is using %quote:
%if (%quote(&alist)=a.*) and (%quote(&blist)=b.*) %then %do;
I think you also need %quote() or %str() around the left side of = sign.
Hello,
%macro a;
%let alist=a.*;
%let blist=b.*;
%if (%bquote(&alist)=%str(a.*)) and (%bquote(&blist)=%str(b.*)) %then %do;
%put TRUE;
%end;
%mend a;
%a
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.