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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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