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;
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;
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?
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?
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.
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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: