BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Macro
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Loko
Barite | Level 11

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

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

One way is using %quote:

%if (%quote(&alist)=a.*) and (%quote(&blist)=b.*) %then %do;

gergely_batho
SAS Employee

I think you also need %quote() or %str() around the left side of = sign.

Loko
Barite | Level 11

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 787 views
  • 6 likes
  • 4 in conversation