Apparent invocation of macro not resolved.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Apparent invocation of macro not resolved.

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;

 


Accepted Solutions
Solution
‎09-28-2016 09:52 AM
Super User
Super User
Posts: 6,842

Re: Apparent invocation of macro not resolved.

[ Edited ]

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


All Replies
Super User
Posts: 19,034

Re: Apparent invocation of macro not resolved.

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? 

Super User
Super User
Posts: 7,682

Re: Apparent invocation of macro not resolved.

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?

Occasional Contributor
Posts: 12

Re: Apparent invocation of macro not resolved.

[ Edited ]

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.

Solution
‎09-28-2016 09:52 AM
Super User
Super User
Posts: 6,842

Re: Apparent invocation of macro not resolved.

[ Edited ]

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;

 

Occasional Contributor
Posts: 12

Re: Apparent invocation of macro not resolved.

The answers works perfectly. Thank you so much for your help.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 2972 views
  • 2 likes
  • 4 in conversation