BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JohnnySas
Calcite | Level 5

%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%'

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

There may be better ways but this works:

 

where name like %unquote(%nrbquote('%str(%%)%superq(catg0)%'));

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

There may be better ways but this works:

 

where name like %unquote(%nrbquote('%str(%%)%superq(catg0)%'));

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Or use a function:

where index(companyname,"&catg0.");

JohnnySas
Calcite | Level 5

Thank YOu. This worked for me

Tom
Super User Tom
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1650 views
  • 2 likes
  • 5 in conversation