<?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: Parenthesis or No Parenthesis in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95161#M26925</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Parenthesis are used for specifying the order of how AND/OR are evaluated. Otherwise I think they're evaluated from left to right, which isn't necessarily what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll add in the business logic in comments as well so it makes sense to me in the future and for updates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE &lt;/P&gt;&lt;P&gt;((Member_Type in ('Loss','Active','Contingent') and Member_Code ne '3') /*Member is active (ne 3) and delinquent*/&lt;/P&gt;&lt;P&gt;or (Member_Code eq '3' and&amp;nbsp; Area = '24') /* OR Member is active and in Los Angeles*/&lt;/P&gt;&lt;P&gt;or&amp;nbsp; (Partner_Code eq '1' and Supvr_Code = '5') ) /* OR Accounts where the partner is senior and supervisor is not*/&lt;/P&gt;&lt;P&gt;and Balance_Owed &amp;gt;0 /*Any of the above AND Accounts that have a balance outstanding*/&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Apr 2013 18:07:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-04-02T18:07:10Z</dc:date>
    <item>
      <title>Parenthesis or No Parenthesis</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95160#M26924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Members as&lt;/P&gt;&lt;P&gt; select ID, L_Name, Join_Date, Member_Type, Area, Member_Code,Partner_Code, Supvr_Code, Refund_Amt, Balance_Owed&lt;/P&gt;&lt;P&gt;&amp;nbsp; from tbl_Membership&lt;/P&gt;&lt;P&gt;where Member_Type in ('Loss','Active','Contingent') and Member_Code ne '3' or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Member_Code eq '3' and&amp;nbsp; Area = '24' or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Partner_Code eq '1' and Supvr_Code = '5' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Balance_Owed &amp;gt;0;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my output, I am getting some records with a zero.&amp;nbsp; I am trying to determine when and where to enclose my or groups and "and' gropus in parenthesis.&amp;nbsp; I do not deal with this many scenarios often so I want to get a good feel for general rules when dealing with an assortment of and vs or groups.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2013 17:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95160#M26924</guid>
      <dc:creator>omega1983</dc:creator>
      <dc:date>2013-04-02T17:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Parenthesis or No Parenthesis</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95161#M26925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Parenthesis are used for specifying the order of how AND/OR are evaluated. Otherwise I think they're evaluated from left to right, which isn't necessarily what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll add in the business logic in comments as well so it makes sense to me in the future and for updates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE &lt;/P&gt;&lt;P&gt;((Member_Type in ('Loss','Active','Contingent') and Member_Code ne '3') /*Member is active (ne 3) and delinquent*/&lt;/P&gt;&lt;P&gt;or (Member_Code eq '3' and&amp;nbsp; Area = '24') /* OR Member is active and in Los Angeles*/&lt;/P&gt;&lt;P&gt;or&amp;nbsp; (Partner_Code eq '1' and Supvr_Code = '5') ) /* OR Accounts where the partner is senior and supervisor is not*/&lt;/P&gt;&lt;P&gt;and Balance_Owed &amp;gt;0 /*Any of the above AND Accounts that have a balance outstanding*/&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Apr 2013 18:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95161#M26925</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-04-02T18:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Parenthesis or No Parenthesis</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95162#M26926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are some references on&lt;/P&gt;&lt;P&gt;Evaluating Logical Expressions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://www.sascommunity.org/wiki/Evaluating_Logical_Expressions" title="http://www.sascommunity.org/wiki/Evaluating_Logical_Expressions"&gt;http://www.sascommunity.org/wiki/Evaluating_Logical_Expressions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the support.sas page on order of precedence of evaluation of logical operators&lt;/P&gt;&lt;H1 class="title"&gt;&lt;/H1&gt;&lt;P&gt;Defining Arithmetic and Logical Expressions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n1alyfc9f4qrten10sd5qz5e1w5q.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n1alyfc9f4qrten10sd5qz5e1w5q.htm"&gt;SAS(R) 9.3 Macro Language: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ron Fehd&amp;nbsp; logically yours&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Parenthesis-or-No-Parenthesis/m-p/95162#M26926</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2013-04-03T14:28:35Z</dc:date>
    </item>
  </channel>
</rss>

