%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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.