<?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: move multiple 'or' statements into one statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617833#M181119</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295821"&gt;@Krueger&lt;/a&gt;, you would need to remove the % and then I think it will work as expected. Or you could use the find()/INDEX() functions as well.</description>
    <pubDate>Thu, 16 Jan 2020 17:34:12 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-01-16T17:34:12Z</dc:date>
    <item>
      <title>move multiple 'or' statements into one statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617824#M181115</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can I write a code make multiple 'OR' statements into one row? please see the code,&amp;nbsp;the new method does not work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table old_method as
select * from sashelp.baseball
where 
upcase(name) like '%BI%'

or 
upcase(name) like '%AI%'&lt;BR /&gt;&lt;BR /&gt;

or
upcase(name) like '%AE%'
/* we have more or statements*/
;
quit;



*--the new method does not work;
proc sql;
create table new_method as
select * from sashelp.baseball
where 
upcase(name) like in('%BI%','%AI%','%AE%');
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 16:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617824#M181115</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2020-01-16T16:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: move multiple 'or' statements into one statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617826#M181116</link>
      <description>&lt;P&gt;EDIT: Looks like this doesn't work the same in SAS so you would have to update the logic below to work in SQL and then use SQL Pass through. I'm sure there are much better alternatives built-in to SAS however.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no combined like and in statement for SQL (may be wrong regarding SAS). However what I would do if using SQL would be something like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table list as
select '%AB%' as var
union all
select '%AI%' as var
union all
select '%AE%' as var;
quit;

proc sql;
create table old_method as
select *
&amp;nbsp; from sashelp.baseball b
&amp;nbsp; join list l on upcase(b.name) like l.var;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617826#M181116</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2020-01-16T17:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: move multiple 'or' statements into one statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617829#M181117</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10531"&gt;@GeorgeSAS&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, you can, but you need to use correct syntax. The LIKE and IN operators cannot be used together like this. You may want to use the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0bj9p4401w3n9n1gmv6tf**bleep**9m.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PRXMATCH function&lt;/A&gt; instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where prxmatch('/BI|AI|AE/i', name);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The pipe character means "or", the "&lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt;" modifier requests case-insensitive search.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 17:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617829#M181117</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-01-16T17:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: move multiple 'or' statements into one statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617833#M181119</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295821"&gt;@Krueger&lt;/a&gt;, you would need to remove the % and then I think it will work as expected. Or you could use the find()/INDEX() functions as well.</description>
      <pubDate>Thu, 16 Jan 2020 17:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617833#M181119</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-16T17:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: move multiple 'or' statements into one statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617859#M181134</link>
      <description>&lt;P&gt;I get a syntax error running as is(for the union all). If I add from table then union all works but at that point it's a completely different approach with just inserting the values into a table and then using the second part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yeah I don't know SAS is weird to me...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data list;
input var $;
datalines;
'AB'
'AE'
'AI'
'BE%'
;
run;

proc sql;
create table old_method as
select upcase(b.name), l.var
  from sashelp.baseball b
  join list l on upcase(b.name) like l.var;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If I swap l.var with 'BE%' it works just fine. Not sure what it's struggling with when I can do the exact same thing in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 18:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/move-multiple-or-statements-into-one-statement/m-p/617859#M181134</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2020-01-16T18:48:38Z</dc:date>
    </item>
  </channel>
</rss>

