<?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: How to use proc sql to select variable that contains ANY of given strings? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64336#M18287</link>
    <description>Excellent!! This is exactly what I wanted.&lt;BR /&gt;
&lt;BR /&gt;
Big thanks. Chris! this poster is resolved.</description>
    <pubDate>Thu, 20 Jan 2011 16:34:13 GMT</pubDate>
    <dc:creator>Fisher</dc:creator>
    <dc:date>2011-01-20T16:34:13Z</dc:date>
    <item>
      <title>How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64324#M18275</link>
      <description>I have a list of strings, now I like to use proc sql to select obs from a dataset that one variable begins or contains ANY of the string in the given string list. There are many strings in the given string list, and the lengths of strings are variable, so I can't use functions such as substring().&lt;BR /&gt;
&lt;BR /&gt;
I tried to do this do this way:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   select * from myds where onevar contains ANY ('str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7');&lt;BR /&gt;
but it doesn't work.  Any better way to do it?  thanks.</description>
      <pubDate>Wed, 19 Jan 2011 14:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64324#M18275</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2011-01-19T14:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64325#M18276</link>
      <description>&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;proc&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;sql&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;*&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;sashelp.class&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;name&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN style="color:#800080;font-family:Courier New;font-size:10pt;"&gt;'Alfred'&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#800080;font-family:Courier New;font-size:10pt;"&gt;'Alice'&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#800080;font-family:Courier New;font-size:10pt;"&gt;'Robert'&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;quit&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;/*&amp;nbsp;on&amp;nbsp;lst&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Age&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Height&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Weight&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Alfred&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;69&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;112.5&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Alice&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;56.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;84&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Robert&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;64.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;128&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2011 15:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64325#M18276</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2011-01-19T15:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64326#M18277</link>
      <description>Thanks.&lt;BR /&gt;
&lt;BR /&gt;
But when the name is 'Alicen', then this obs will NOT be picked up. I mean comparing whole or part of the strings, not only whole string. In your example, you only check if the name value is equal to one of the given strings.</description>
      <pubDate>Wed, 19 Jan 2011 15:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64326#M18277</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2011-01-19T15:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64327#M18278</link>
      <description>So, in your SELECT and WHERE clauses, you will need to use "LIKE"  or "CONTAINS" and separate each data-value test using an OR condition.  It is possible to generate such argument strings with SAS macro code, if so inclined.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 19 Jan 2011 16:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64327#M18278</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-19T16:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64328#M18279</link>
      <description>Thanks Scott.&lt;BR /&gt;
My string list is very long, if I use LIKE or CONTAINS, then I have to type these keywords and every string in the list which is boring.</description>
      <pubDate>Wed, 19 Jan 2011 16:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64328#M18279</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2011-01-19T16:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64329#M18280</link>
      <description>As suggested, you can write a SAS macro to generate the necessary code from your list of values.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post-reply:&lt;BR /&gt;
macro generate code from list site:sas.com</description>
      <pubDate>Wed, 19 Jan 2011 16:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64329#M18280</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-19T16:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64330#M18281</link>
      <description>I found I can use data step to do it:&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
   set sashelp.class;&lt;BR /&gt;
   if name in: ( 'Al', 'Robert');&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
which picks up 'Alfred', 'Alice' and 'Robert'. &lt;BR /&gt;
I am just curious if there is an equivalent way in proc sql.</description>
      <pubDate>Wed, 19 Jan 2011 16:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64330#M18281</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2011-01-19T16:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64331#M18282</link>
      <description>No equivalent with PROC SQL (reason for suggesting macro code approach) - consider using a WHERE statement instead of IF (performance considerations, however data-volume dependent, with the DATA step approach).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post-reply:&lt;BR /&gt;
&lt;BR /&gt;
proc sql select where clause operators site:sas.com</description>
      <pubDate>Wed, 19 Jan 2011 16:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64331#M18282</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-19T16:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64332#M18283</link>
      <description>proc sql does not have in: but it does have eqt. This should work fine assuming that the lookup table(names below) does not contain entries that eqt themselves, like: "Al" and "A". (guess why?)&lt;BR /&gt;&lt;BR /&gt;
&lt;BR /&gt;  &lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;proc&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;sql&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;create&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;names&amp;nbsp;(name&amp;nbsp;character(&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#008080;font-family:Courier New;font-size:10pt;"&gt;20&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;insert&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;names&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;name=&lt;/SPAN&gt;&lt;SPAN style="color:#800080;font-family:Courier New;font-size:10pt;"&gt;"Al"&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;insert&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;names&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;name=&lt;/SPAN&gt;&lt;SPAN style="color:#800080;font-family:Courier New;font-size:10pt;"&gt;"Robert"&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#008080;font-family:Courier New;font-size:10pt;"&gt;c.&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;*&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;sashelp.class&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;c,&amp;nbsp;names&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;n&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#0000FF;font-family:Courier New;font-size:10pt;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;c.name&amp;nbsp;eqt&amp;nbsp;n.name;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="color:#000080;font-family:Courier New;font-size:10pt;"&gt;quit&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;/*&amp;nbsp;on&amp;nbsp;lst&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Age&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Height&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Weight&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Alfred&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;69&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;112.5&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Alice&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;56.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;84&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Robert&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;64.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;128&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P style="padding:0"&gt;&lt;SPAN style="color:#008000;font-family:Courier New;font-size:10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2011 17:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64332#M18283</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2011-01-19T17:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64333#M18284</link>
      <description>The original request referred to the string being "CONTAIN"ed in the variable.  The existing solutions have found it when the variable started with the string and didn't ignore case.  If those two criteria are required, the following code accomplishes that.&lt;BR /&gt;
&lt;BR /&gt;
data allstrings;&lt;BR /&gt;
  input string $3.;&lt;BR /&gt;
cards;&lt;BR /&gt;
red&lt;BR /&gt;
al&lt;BR /&gt;
ber&lt;BR /&gt;
;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select 'lowcase(name) contains '''||trim(lowcase(string))||'''' &lt;BR /&gt;
               into :strings separated by ' or '&lt;BR /&gt;
    from allstrings&lt;BR /&gt;
    order by 1;&lt;BR /&gt;
  create table subset as&lt;BR /&gt;
    select *&lt;BR /&gt;
      from sashelp.class&lt;BR /&gt;
      where &amp;amp;strings;&lt;BR /&gt;
  quit;</description>
      <pubDate>Wed, 19 Jan 2011 21:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64333#M18284</guid>
      <dc:creator>advoss</dc:creator>
      <dc:date>2011-01-19T21:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64334#M18285</link>
      <description>&lt;P&gt;To answer post @ Jan 19, 2011 11:13 AM &lt;BR /&gt; &lt;BR /&gt; &amp;gt;I am just curious if there is an equivalent way in proc sql. &lt;BR /&gt; &lt;BR /&gt; There is: operators =: or in: can be used to subset a sas table in a sql statement if they are used as a dataset option instead of a sql clause.&lt;BR /&gt; &lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select NAME from SASHELP.CLASS(where=(NAME in:('A','B')));
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS macro approach suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13628"&gt;@advoss&lt;/a&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The original request referred to the string being "CONTAIN"ed in the variable. The existing solutions have found it when the variable started with the string and didn't ignore case. If those two criteria are required, the following code accomplishes that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data allstrings;
  input string $3.;
  cards;
red
al
ber
;

proc sql noprint;
  select 'lowcase(name) contains '''||trim(lowcase(string))||''''&amp;nbsp;
    into :strings separated by ' or '
      from allstrings
        order by 1;
  create table subset as
    select *
      from sashelp.class
        where &amp;amp;strings;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 06 Mar 2018 16:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64334#M18285</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-03-06T16:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64335#M18286</link>
      <description>&amp;gt; I have a list of strings, now I like to use proc sql&lt;BR /&gt;
&amp;gt; to select obs from a dataset that one variable begins&lt;BR /&gt;
 &lt;BR /&gt;
almost &lt;BR /&gt;
 &lt;BR /&gt;
see the tip from Amadeus on using ANY and ALL in proc sql, at&lt;BR /&gt;
&lt;A href="http://www.amadeus.co.uk/sas-technical-services/tips-and-techniques/sql/using-the-any-and-all-operators-in-proc-sql/" target="_blank"&gt;http://www.amadeus.co.uk/sas-technical-services/tips-and-techniques/sql/using-the-any-and-all-operators-in-proc-sql/&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Thu, 20 Jan 2011 16:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64335#M18286</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-01-20T16:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64336#M18287</link>
      <description>Excellent!! This is exactly what I wanted.&lt;BR /&gt;
&lt;BR /&gt;
Big thanks. Chris! this poster is resolved.</description>
      <pubDate>Thu, 20 Jan 2011 16:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64336#M18287</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2011-01-20T16:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64337#M18288</link>
      <description>Hi Peter,&lt;BR /&gt;
&lt;BR /&gt;
I didn't know this syntax, thanks fot the link.&lt;BR /&gt;
&lt;BR /&gt;
On the other hand I fail to see what its point is. The examples given are just as easy to do in a more standard fashion. When would you use the all and any operators? &lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data mozart_shoes;&lt;BR /&gt;
  format id z3. name $char24.;&lt;BR /&gt;
  input id name $ &amp;amp; sales;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
001 Super-tread trainer   50000&lt;BR /&gt;
002 X-Pro sports trainer  60000&lt;BR /&gt;
003 Road runner deluxe    55000&lt;BR /&gt;
004 Triathlon special     30000&lt;BR /&gt;
run;&lt;BR /&gt;
data top_brands;&lt;BR /&gt;
  format name $char24.;&lt;BR /&gt;
  input name $ &amp;amp; sales;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
Cougar 500          58000&lt;BR /&gt;
Mike running pro    56000&lt;BR /&gt;
Abibas Super-tread  53000&lt;BR /&gt;
run;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select name, sales&lt;BR /&gt;
    from mozart_shoes&lt;BR /&gt;
    where sales gt any (select sales from top_brands);&lt;BR /&gt;
  select name, sales&lt;BR /&gt;
    from mozart_shoes&lt;BR /&gt;
    where sales gt (select min(sales) from top_brands);&lt;BR /&gt;
&lt;BR /&gt;
  select name, sales&lt;BR /&gt;
    from mozart_shoes&lt;BR /&gt;
    where sales gt all (select sales from top_brands);&lt;BR /&gt;
  select name, sales&lt;BR /&gt;
    from mozart_shoes&lt;BR /&gt;
    where sales gt (select max(sales) from top_brands);&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 24 Jan 2011 02:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64337#M18288</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2011-01-24T02:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64338#M18289</link>
      <description>Chris&lt;BR /&gt;
I agree with you, those examples don't demand ANY or ALL.&lt;BR /&gt;
However, I googled sql all any and found sql discussion group postings which made more sense of the feature. &lt;BR /&gt;
Nice to know it's there.&lt;BR /&gt;
Peter</description>
      <pubDate>Mon, 24 Jan 2011 13:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64338#M18289</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-01-24T13:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64339#M18290</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
can I ask a related question ---&amp;gt; I am also trying to search strings with proc sql (extracting data from DB2 using PROC SQL) by using WHERE condition (and need to avoid using data step) to reduce the number of observations extracted.&lt;BR /&gt;
&lt;BR /&gt;
My question is ---&amp;gt;&lt;BR /&gt;
Is there a way to modify "in:" from the below to able to search any substring? &lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select NAME from SASHELP.CLASS(where=(NAME in:('A','B')));&lt;BR /&gt;
quit; &lt;BR /&gt;
&lt;BR /&gt;
For example,&lt;BR /&gt;
I want to find  all names that have "ane" in the string, But "in:" only captures strings that start with "ane". &lt;BR /&gt;
&lt;BR /&gt;
Could you kindly advise? Thank you very much.</description>
      <pubDate>Wed, 20 Apr 2011 15:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64339#M18290</guid>
      <dc:creator>SAS_user_n</dc:creator>
      <dc:date>2011-04-20T15:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64340#M18291</link>
      <description>You could use something like:&lt;BR /&gt;
&lt;BR /&gt;
data strings;&lt;BR /&gt;
  input string $upcase.;&lt;BR /&gt;
  cards;&lt;BR /&gt;
ro&lt;BR /&gt;
an&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select "upcase(NAME) contains '"||trim(string)||"'"&lt;BR /&gt;
    into :strings&lt;BR /&gt;
      separated by " or "&lt;BR /&gt;
	    from strings&lt;BR /&gt;
  ;&lt;BR /&gt;
  select NAME&lt;BR /&gt;
    from SASHELP.CLASS (where=(&amp;amp;strings.))&lt;BR /&gt;
  ;&lt;BR /&gt;
quit; &lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
-----&lt;BR /&gt;
&amp;gt; Hello,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; can I ask a related question ---&amp;gt; I am also trying to&lt;BR /&gt;
&amp;gt; search strings with proc sql (extracting data from&lt;BR /&gt;
&amp;gt; DB2 using PROC SQL) by using WHERE condition (and&lt;BR /&gt;
&amp;gt; need to avoid using data step) to reduce the number&lt;BR /&gt;
&amp;gt; of observations extracted.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; My question is ---&amp;gt;&lt;BR /&gt;
&amp;gt; Is there a way to modify "in:" from the below to able&lt;BR /&gt;
&amp;gt; to search any substring? &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; proc sql;&lt;BR /&gt;
&amp;gt; select NAME from SASHELP.CLASS(where=(NAME&lt;BR /&gt;
&amp;gt; in:('A','B')));&lt;BR /&gt;
&amp;gt; quit; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For example,&lt;BR /&gt;
&amp;gt; I want to find  all names that have "ane" in the&lt;BR /&gt;
&amp;gt; string, But "in:" only captures strings that start&lt;BR /&gt;
&amp;gt; with "ane". &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Could you kindly advise? Thank you very much.</description>
      <pubDate>Wed, 20 Apr 2011 16:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64340#M18291</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-20T16:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64341#M18292</link>
      <description>Equivalent of in: in PROC SQL is supposed to be inT.  But it work selective.  Not sure of the pattern.  &lt;BR /&gt;
&lt;BR /&gt;
I would be happy to know why this happens.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Sandy.</description>
      <pubDate>Wed, 20 Apr 2011 18:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64341#M18292</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2011-04-20T18:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc sql to select variable that contains ANY of given strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64342#M18293</link>
      <description>Thank you all for suggestions. I was able to resolve my problem this way:&lt;BR /&gt;
(I want to only select if a char var has "&lt;B&gt;ab cdcdcd ef&lt;/B&gt;" appearing in any part of the string).&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 connect to db2 ;&lt;BR /&gt;
  create table temp as&lt;BR /&gt;
   select * from connnection to db2&lt;BR /&gt;
    (select x y z&lt;BR /&gt;
      from Q&lt;BR /&gt;
&lt;B&gt;      where x like '%ab cdcdcd ef%'&lt;/B&gt;      &lt;BR /&gt;
      order by x);&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 25 Apr 2011 12:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-proc-sql-to-select-variable-that-contains-ANY-of/m-p/64342#M18293</guid>
      <dc:creator>SAS_user_n</dc:creator>
      <dc:date>2011-04-25T12:48:39Z</dc:date>
    </item>
  </channel>
</rss>

