<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Alternative to &amp;quot;Like any&amp;quot; of teradata with a macro variable in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/929467#M365719</link>
    <description>This is a simple solution that will work if and only if the values have the same length. 
In the example, the search parameter is assumed to be in the beginning of the string.

DATA EMPLOYEES;
 LENGTH LASTNAME $9;
 INPUT @1 LASTNAME;
cards;
JONES
SMITH
Doe
wesson
CRISCO
;
run;

proc sql number;
select lastname from employees
where upper(substr(strip(lastname),1,3)) 
      in ('SMI', 'WES', 'BRO', 'DOE');
quit;</description>
    <pubDate>Thu, 23 May 2024 19:04:54 GMT</pubDate>
    <dc:creator>jdfrost</dc:creator>
    <dc:date>2024-05-23T19:04:54Z</dc:date>
    <item>
      <title>Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736307#M229350</link>
      <description>&lt;P&gt;I have a code similiar to this&lt;/P&gt;
&lt;P&gt;the macro variable has Value&amp;nbsp; '%678900','%625890','%827189'&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table as sec;
select * from table1 
where var like any (&amp;amp;Value) ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It throws an error ERROR: FUNCTION ANY COULD NOT BE LOCATED. Before to escape using like any I used PRXMATCH('~DENIED|INVALID~i',UPPER(DESC)). How to use with macro in proc sql statement?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 02:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736307#M229350</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2021-04-22T02:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736311#M229354</link>
      <description>&lt;P&gt;AFAIK there is no equivalent LIKE list in SAS SQL. However if you could describe the variable you are selecting on in more detail. For example, does it always contain the same number of characters? If so then you could use the SUBSTR function to choose just the last six characters of the string to compare.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 02:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736311#M229354</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-04-22T02:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736319#M229358</link>
      <description>&lt;P&gt;The 2 or third character is a "-" after which is numbers which are stored in the macro. If possible how can I save the values in a macro and how do I use it?. I am saving the values in macro by&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL NOPRINT;
SELECT quote(cats('%',value),"'")  
INTO :value  separated by ", "
FROM IDS_CODE 
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Apr 2021 03:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736319#M229358</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2021-04-22T03:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736325#M229364</link>
      <description>&lt;P&gt;Maybe something like this will work then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table as sec;
select * from table1 
where scan(var,2,'-') in ('123456','789012') ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:07:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736325#M229364</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-04-22T05:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736332#M229371</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sql noprint;
  select VALUE into :values separated by "|"
  from IDS_CODE ;

  create table SEC as 
  select * from TABLE1
  where prxmatch("/.*-(&amp;amp;values)/",VAR) ;
quit;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 07:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/736332#M229371</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-22T07:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/929467#M365719</link>
      <description>This is a simple solution that will work if and only if the values have the same length. 
In the example, the search parameter is assumed to be in the beginning of the string.

DATA EMPLOYEES;
 LENGTH LASTNAME $9;
 INPUT @1 LASTNAME;
cards;
JONES
SMITH
Doe
wesson
CRISCO
;
run;

proc sql number;
select lastname from employees
where upper(substr(strip(lastname),1,3)) 
      in ('SMI', 'WES', 'BRO', 'DOE');
quit;</description>
      <pubDate>Thu, 23 May 2024 19:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/929467#M365719</guid>
      <dc:creator>jdfrost</dc:creator>
      <dc:date>2024-05-23T19:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to "Like any" of teradata with a macro variable in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/929480#M365721</link>
      <description>&lt;P&gt;If you want to test the last 6 characters in a variable first remove the % from your macro variable.&lt;/P&gt;
&lt;P&gt;Then use SUBSTRN() to get the last 6 characters and see if the result is in your new list of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let value='%678900','%625890','%827189';
%let value6 = %sysfunc(transtrn(%superq(value),%str(%%),));

proc sql ;
create table want as
  select * from table1 
  where substrn(var,length(var)-5)  like (&amp;amp;Value6)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 May 2024 20:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-to-quot-Like-any-quot-of-teradata-with-a-macro/m-p/929480#M365721</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-23T20:11:03Z</dc:date>
    </item>
  </channel>
</rss>

