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

Hi,

I got an error message when the following code were submitted. It says "Apparent invocation of macro not resolved.". Does anyone hvae any insight? Thank you.

 

proc sql;

create table a as

select distinct *

from test data

where lower(last_name) like "%&proj%";

quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Probably the easiest is to build up the string with the % in it in a way that does not trigger the macro processor.

Here is one way.

%let name=fred;
proc sql noprint;
create table a as
 select distinct *
 from sashelp.class
 where lower(name) like '%'||"&name"||'%'
;
quit;

 

View solution in original post

5 REPLIES 5
Reeza
Super User

SAS is looking for a macro because you have %proj

 

its a warning not an error though? 

 

Can you use the find or index function instead if you need to avoid the warning? 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

It is this code line:

where lower(last_name) like "%&proj%";

If you use macro constructs = % or & witihin double quotes, then then macro preprocessor is invoked.  Now it will resolve &proj. to its value, and then look for a macro called %<proj value>.  

 

Use SAS functions to search for a string - index() for instance.  Or avoid using macro paramters, is there any reason why &proj is used?

lionking19063
Fluorite | Level 6

I used index as you mentioned, it works fine. Just wonder if there is a way to fix the error in the existing SAS codes instead of trying another way. Thanks.

Tom
Super User Tom
Super User

Probably the easiest is to build up the string with the % in it in a way that does not trigger the macro processor.

Here is one way.

%let name=fred;
proc sql noprint;
create table a as
 select distinct *
 from sashelp.class
 where lower(name) like '%'||"&name"||'%'
;
quit;

 

lionking19063
Fluorite | Level 6
The answers works perfectly. Thank you so much for your help.

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
  • 5 replies
  • 15376 views
  • 2 likes
  • 4 in conversation