<?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: help with if and or statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882748#M348763</link>
    <description>&lt;P&gt;My examples are only there to illustrate what your conditions as posted really do.&lt;/P&gt;
&lt;P&gt;It is now up to you to set the parentheses in a way so that the code reflects what you want to achieve.&lt;/P&gt;
&lt;P&gt;If all the ORs in a compound condition should only play a role if the first condition is met, you need to do&lt;/P&gt;
&lt;PRE&gt;if a and (x or y or z)&lt;/PRE&gt;
&lt;P&gt;Review both of your IF statements in light of this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 07:53:20 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-06-28T07:53:20Z</dc:date>
    <item>
      <title>help with if and or statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882735#M348757</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code and clearly I am not doing something right.&lt;/P&gt;&lt;P&gt;The value of Rule3 is return the value of "No", therefore I want the value of "&lt;CODE class=""&gt;RegOff"&amp;nbsp;to&amp;nbsp;be&amp;nbsp;"No",&amp;nbsp;but&amp;nbsp;if&amp;nbsp;the&amp;nbsp;value&amp;nbsp;of&amp;nbsp;Rule3&amp;nbsp;is&amp;nbsp;"Yes",&amp;nbsp;then&amp;nbsp;apply&amp;nbsp;the&amp;nbsp;and&amp;nbsp;plus&amp;nbsp;or&amp;nbsp;statements.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;Sorry&amp;nbsp;if&amp;nbsp;this&amp;nbsp;is&amp;nbsp;an&amp;nbsp;easy&amp;nbsp;one,&amp;nbsp;but&amp;nbsp;perhaps&amp;nbsp;I've&amp;nbsp;been&amp;nbsp;looking&amp;nbsp;at&amp;nbsp;it&amp;nbsp;too&amp;nbsp;long&amp;nbsp;and&amp;nbsp;my&amp;nbsp;head&amp;nbsp;is&amp;nbsp;going&amp;nbsp;in&amp;nbsp;circles.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;	if 'INT Type'n =1  and RGO=1 or IDF=1 then Rule3="Yes";
	else Rule3="No";
    if Rule3="Yes" and ADM &amp;gt;0 or ALC &amp;gt;0 or CAR&amp;gt;0 or CDM &amp;gt;0 or MPR &amp;gt;0 or NCP &amp;gt;0 or PTR &amp;gt;0 or DMA &amp;gt;0 or DMC &amp;gt;0 or IDD &amp;gt;0 Then RegOff="Yes";
	else RegOff="No";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Haydn&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 04:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882735#M348757</guid>
      <dc:creator>Haydo</dc:creator>
      <dc:date>2023-06-28T04:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: help with if and or statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882738#M348759</link>
      <description>&lt;P&gt;IF is a &lt;EM&gt;statement&lt;/EM&gt;, OR is an&amp;nbsp;&lt;EM&gt;operator&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In logic, AND takes precedence over OR. Therefore your conditions are equivalent to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ('INT Type'n =1  and RGO=1) or IDF=1 then Rule3="Yes";
if (Rule3="Yes" and ADM &amp;gt;0) or ALC &amp;gt;0 or CAR&amp;gt;0 or CDM &amp;gt;0 or MPR &amp;gt;0 or NCP &amp;gt;0 or PTR &amp;gt;0 or DMA &amp;gt;0 or DMC &amp;gt;0 or IDD &amp;gt;0 then RegOff="Yes";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2023 05:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882738#M348759</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-28T05:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: help with if and or statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882739#M348760</link>
      <description>Hi Kurt,&lt;BR /&gt;&lt;BR /&gt;Thanks for your quick response. I copied your code and Rule 3 is blank (as desired), however RegOff is returning the value of "Yes". But given Rule 3 does not have the value of "Yes", it should not.</description>
      <pubDate>Wed, 28 Jun 2023 05:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882739#M348760</guid>
      <dc:creator>Haydo</dc:creator>
      <dc:date>2023-06-28T05:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: help with if and or statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882748#M348763</link>
      <description>&lt;P&gt;My examples are only there to illustrate what your conditions as posted really do.&lt;/P&gt;
&lt;P&gt;It is now up to you to set the parentheses in a way so that the code reflects what you want to achieve.&lt;/P&gt;
&lt;P&gt;If all the ORs in a compound condition should only play a role if the first condition is met, you need to do&lt;/P&gt;
&lt;PRE&gt;if a and (x or y or z)&lt;/PRE&gt;
&lt;P&gt;Review both of your IF statements in light of this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 07:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882748#M348763</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-28T07:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: help with if and or statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882807#M348804</link>
      <description>&lt;P&gt;Hint: if you have many numeric variables and you want to find if any (one or more) of them have a value greater than 0 you can reduce code like this (Assuming the intent is to use all of them to get one logical result)&lt;/P&gt;
&lt;PRE&gt; ADM &amp;gt;0 or ALC &amp;gt;0 or CAR&amp;gt;0 or CDM &amp;gt;0 or MPR &amp;gt;0 or NCP &amp;gt;0 or PTR &amp;gt;0 or DMA &amp;gt;0 or DMC &amp;gt;0 or IDD &amp;gt;0&lt;/PRE&gt;
&lt;P&gt;shorter:&lt;/P&gt;
&lt;PRE&gt;max( ADM, ALC, CAR, CDM, MPR, NCP, PTR, DMA, DMC, IDD)&amp;gt;0&lt;/PRE&gt;
&lt;P&gt;You would have to provide values of the variables, the incorrect result and the expected result for the values to determine the actual issues in your comparison approach.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 14:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-if-and-or-statements/m-p/882807#M348804</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-28T14:45:06Z</dc:date>
    </item>
  </channel>
</rss>

