%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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.