<?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 multiple or conditions in where clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407157#M99197</link>
    <description>&lt;P&gt;I have a program in which in proc sql i need to use multiple where conditions&amp;nbsp; that is&amp;nbsp;&lt;/P&gt;&lt;P&gt;where 20 gt win1 lt 30 or 20 gt win2 lt 30 or 20 gt win3 lt 30................till win20.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way not to use multiple or conditions?&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 08:20:04 GMT</pubDate>
    <dc:creator>mj5</dc:creator>
    <dc:date>2017-10-25T08:20:04Z</dc:date>
    <item>
      <title>multiple or conditions in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407157#M99197</link>
      <description>&lt;P&gt;I have a program in which in proc sql i need to use multiple where conditions&amp;nbsp; that is&amp;nbsp;&lt;/P&gt;&lt;P&gt;where 20 gt win1 lt 30 or 20 gt win2 lt 30 or 20 gt win3 lt 30................till win20.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way not to use multiple or conditions?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 08:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407157#M99197</guid>
      <dc:creator>mj5</dc:creator>
      <dc:date>2017-10-25T08:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: multiple or conditions in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407159#M99198</link>
      <description>&lt;P&gt;No. You'll have to code all separate conditions. But you can automate that coding with macro preprocessing.&lt;/P&gt;
&lt;P&gt;BTW,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;20 gt win1 lt 30&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is equivalent to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;win1 lt 20&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 08:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407159#M99198</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-25T08:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: multiple or conditions in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407164#M99201</link>
      <description>&lt;P&gt;There are few ways to do it, but assuming the win should be&lt;STRONG&gt; in a range of values&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;(See &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;note):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro chk;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%do i=1 to 19;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IF
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %str(&amp;nbsp; &amp;lt;limit1&amp;gt; le win&amp;amp;i le &amp;lt;limit2&amp;gt; or);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %str( &amp;lt;limit1&amp;gt; le win20 le &amp;lt;limit2&amp;gt;; );
&amp;nbsp; &amp;nbsp; %mend;
&amp;nbsp; &amp;nbsp; &amp;nbsp;data want; /* or sql step */
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set have;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%chk;
&amp;nbsp; &amp;nbsp; &amp;nbsp;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) Use datasetep instead sql:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
      array winx win1 - win20;
      result = 0;
      do i=1 to 20;
           result = result or (&amp;lt;limit1&amp;gt; le winx(i) le &amp;lt;limit2&amp;gt;);
           if result = 1 then leave;  /* enough to find the first */
      end;
      if result = 1;
     drop result;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 08:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407164#M99201</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T08:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: multiple or conditions in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407165#M99202</link>
      <description>&lt;P&gt;There are always several ways to approach a problem.&amp;nbsp; Your main issue here is that your data is not modelled in a way that is easily programmable in SQL.&amp;nbsp; SQL was developed for relational databases, so this means lots of tables with unique data and id's linking them.&amp;nbsp; These tables were normalised - data going down the page rather than across.&amp;nbsp; Unfortunately nowadays a lot of "Excel thinking" has crept in and people are trying to code against transposed (goes across the page) data.&amp;nbsp; From what you post, if your data looked like this:&lt;/P&gt;
&lt;P&gt;WIN_NO&amp;nbsp; &amp;nbsp;RESULT&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&lt;/P&gt;
&lt;P&gt;Your where clause would resolve to:&lt;/P&gt;
&lt;PRE&gt;where RESULT between 20 and 30;&lt;/PRE&gt;
&lt;P&gt;So you can see quite clearly that the major part of the process is the data modelling - this is almost always the case, arrange and process your data so the code that needs to run against it is a simple as possible - forget the "I have to use Excel for my output so can only work that way" and leave that for the final transpose and report procedures to deal with.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 08:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-or-conditions-in-where-clause/m-p/407165#M99202</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-25T08:47:31Z</dc:date>
    </item>
  </channel>
</rss>

