DATA Step, Macro, Functions and more

proc sql escape character?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 90
Accepted Solution

proc sql escape character?

Hello all,

I see a few topics here on escape character but am not sure they work for proc sql or maybe I am doing somting wrong... 

example string:

Y:\mydir\mysubdir\myfile.txt

Y:\mydir2\mysubdir\myfi%le.txt

 

 

proc sql;
create table list_of_maybe_bad as
select
        Path_File,
        length(Path_File) as lh_Path_File,
        trimn(Path_File) as Path_File1,  
/*...*/
from list_of_working
where upcase(Path_File) not like "D:\SOFTWARE\%"    /* Do not search our Software repostitory */
and Path_File like '%\%%'
;
quit;

In my case i need to return just the second file.   I have tryied '%%%'      '%\%%'     '%/%%'   TIA.


Accepted Solutions
Solution
‎01-07-2016 05:00 PM
Trusted Advisor
Posts: 1,115

Re: proc sql escape character?

According to the documentation, you can choose your own escape character (i.e. ideally a character which does definitely not occur in the strings you work with): If '^' was such a character, the WHERE condition

Path_File like '%^%%' escape '^'

would match any string which contains a percent sign.

 

View solution in original post


All Replies
Solution
‎01-07-2016 05:00 PM
Trusted Advisor
Posts: 1,115

Re: proc sql escape character?

According to the documentation, you can choose your own escape character (i.e. ideally a character which does definitely not occur in the strings you work with): If '^' was such a character, the WHERE condition

Path_File like '%^%%' escape '^'

would match any string which contains a percent sign.

 

Frequent Contributor
Posts: 90

Re: proc sql escape character?

I see I should have been looking up like...  Thank you.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 1572 views
  • 1 like
  • 2 in conversation