%let catg0 = COMPANY ABC;
proc sql;
create table XYU
as select
a.* from
tableb a
where companyname like %nrstr(%')%str(%%)&&catg0%nrstr(%%)%str(%'));
run;
How do I make it resolve to :
where companyname like '%COMPANY ABC%'
There may be better ways but this works:
where name like %unquote(%nrbquote('%str(%%)%superq(catg0)%'));
There may be better ways but this works:
where name like %unquote(%nrbquote('%str(%%)%superq(catg0)%'));
Couldn't that be solved by
data xyu;
set tableb;
where index(companyname,"&catg0.");
run;
?
Or use a function:
where index(companyname,"&catg0.");
Thank YOu. This worked for me
It is a pain trying to do that in macro language, but since you are already generating some SAS code why not generate some SAS code to add the quotes and percent signs?
data _null_;
call symputx('catg0_like',quote('%'||symget('catg0')||'%',"'"));
run;
proc sql noprint feedback;
create table XYU as
select a.*
from tableb a
where companyname like &catg0_like
;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.