<?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: Filtering Data - Efficiency Gains by removing ANDs? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862881#M340839</link>
    <description>&lt;P&gt;AFAIK, there is no difference in efficiency between the two ways of expressing the filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The advantage to the second may be, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;remarked, that it is easier to read. The problem with it is that e.g. a&amp;lt;b&amp;lt;c is a rather specific SAS shorthand, which does not work the same way in other languages (in standard SQL you get a syntax error, and in C++ it may mean something completely different).&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 08:41:35 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2023-03-08T08:41:35Z</dc:date>
    <item>
      <title>Filtering Data - Efficiency Gains by removing ANDs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862738#M340778</link>
      <description>&lt;P&gt;I know this subject line is not the best, but I am curious if there are any efficiency gains from rewriting a filter:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;numeric_variable &amp;gt; 0 AND numeric_variable &amp;lt; 50000&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to just be this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;0 &amp;lt; numeric_variable &amp;lt; 50000&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know using subsetting WHERE is better than IF, when possible, but interested to know if there is any background logic that is applied when using filter example #2 that increases efficiency/speed of processing, or if there are performance differences between using them in DATA steps vs. PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any guidance!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862738#M340778</guid>
      <dc:creator>GBL__</dc:creator>
      <dc:date>2023-03-07T17:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering Data - Efficiency Gains by removing ANDs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862764#M340791</link>
      <description>&lt;P&gt;In general SQL is slower than a data step. If nothing else, the implied overhead available for the aggregate functions across observations is an issue. You may not see any practical difference with fewer than many thousands of observations though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the bigger efficiencies, IMHO, is that when I see code with&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;0 &amp;lt; numeric_variable &amp;lt; 50000&lt;/LI-CODE&gt;
&lt;P&gt;it is pretty obvious what is intended. Between indentation choices and lengths of statement lines that may not be quit as obvious with the 'and' involved.&lt;/P&gt;
&lt;P&gt;That advantage becomes more obvious with more complex expressions like&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;0 &amp;lt; numeric_variable &amp;lt; another_variable &amp;lt; 50000&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 19:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862764#M340791</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T19:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering Data - Efficiency Gains by removing ANDs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862881#M340839</link>
      <description>&lt;P&gt;AFAIK, there is no difference in efficiency between the two ways of expressing the filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The advantage to the second may be, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;remarked, that it is easier to read. The problem with it is that e.g. a&amp;lt;b&amp;lt;c is a rather specific SAS shorthand, which does not work the same way in other languages (in standard SQL you get a syntax error, and in C++ it may mean something completely different).&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 08:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/862881#M340839</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-03-08T08:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering Data - Efficiency Gains by removing ANDs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/863425#M341070</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for your response!&amp;nbsp; I agree completely that readability is key and was my major reason for using this type of filter/subsetting layout.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 13:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/863425#M341070</guid>
      <dc:creator>GBL__</dc:creator>
      <dc:date>2023-03-10T13:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering Data - Efficiency Gains by removing ANDs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/863427#M341072</link>
      <description>Thank you for your response!  I also agree that the 'a &amp;lt; b &amp;lt; c' filtering is rather specific SAS shorthand, but nonetheless is probably most appropriate (in my situation, at least)</description>
      <pubDate>Fri, 10 Mar 2023 13:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-Data-Efficiency-Gains-by-removing-ANDs/m-p/863427#M341072</guid>
      <dc:creator>GBL__</dc:creator>
      <dc:date>2023-03-10T13:16:29Z</dc:date>
    </item>
  </channel>
</rss>

