<?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: IF clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218655#M40297</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are just having a logic problem.&lt;/P&gt;&lt;P&gt;Your first conditional is of the form&amp;nbsp; (NOT A &lt;SPAN style="text-decoration: underline;"&gt;or&lt;/SPAN&gt; NOT B)&amp;nbsp;&amp;nbsp; Since it is never possible for A and B to be true at the same time (this would mean that product is both 'auto' and 'Cd' at the same time) your condition is always true.&lt;/P&gt;&lt;P&gt;Your second is of the form (NOT A &lt;SPAN style="text-decoration: underline;"&gt;AND&lt;/SPAN&gt; NOT B) and so actually succeeds in sub-setting the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So instead of &lt;/P&gt;&lt;P&gt;if product ne 'auto' or product ne 'Cd' then output ;&lt;/P&gt;&lt;P&gt;you want&lt;/P&gt;&lt;P&gt;if product ne 'auto' AND product ne 'Cd' then output ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;You can reformulate (NOT A AND NOT B) to NOT (A OR B) using basic logic and get &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if&amp;nbsp; not (product = 'auto' OR product = 'Cd') then output ;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;This can also be written as &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if&amp;nbsp; product not in ('auto','Cd') then output ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 May 2015 16:18:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-05-25T16:18:08Z</dc:date>
    <item>
      <title>IF clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218652#M40294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to extract the data which does not have the products 'auto' and 'cd'. I tried the code below,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input product $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;auto&lt;/P&gt;&lt;P&gt;Cd&lt;/P&gt;&lt;P&gt;WIS&lt;/P&gt;&lt;P&gt;PL&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if product ne 'auto' or product ne 'Cd' then output ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not working. Any possibilities to achive this one If (or where) clause? I know we can achive with two if clauses like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if product ne 'auto';&lt;/P&gt;&lt;P&gt;if product ne 'Cd';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 11:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218652#M40294</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-05-25T11:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: IF clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218653#M40295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if product not in ('auto'&amp;nbsp; 'Cd')&amp;nbsp; then output ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 11:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218653#M40295</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-25T11:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: IF clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218654#M40296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For the "help me understand why my code doesn't work?" perspective.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Review your use of OR versus AND in your IF &amp;lt;expression&amp;gt; THEN OUTPUT;&amp;nbsp;&amp;nbsp;&amp;nbsp; statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, also consider that the two IF statements, as you have them coded, will work correctly, given your desired result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 15:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218654#M40296</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2015-05-25T15:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: IF clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218655#M40297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are just having a logic problem.&lt;/P&gt;&lt;P&gt;Your first conditional is of the form&amp;nbsp; (NOT A &lt;SPAN style="text-decoration: underline;"&gt;or&lt;/SPAN&gt; NOT B)&amp;nbsp;&amp;nbsp; Since it is never possible for A and B to be true at the same time (this would mean that product is both 'auto' and 'Cd' at the same time) your condition is always true.&lt;/P&gt;&lt;P&gt;Your second is of the form (NOT A &lt;SPAN style="text-decoration: underline;"&gt;AND&lt;/SPAN&gt; NOT B) and so actually succeeds in sub-setting the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So instead of &lt;/P&gt;&lt;P&gt;if product ne 'auto' or product ne 'Cd' then output ;&lt;/P&gt;&lt;P&gt;you want&lt;/P&gt;&lt;P&gt;if product ne 'auto' AND product ne 'Cd' then output ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;You can reformulate (NOT A AND NOT B) to NOT (A OR B) using basic logic and get &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if&amp;nbsp; not (product = 'auto' OR product = 'Cd') then output ;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;This can also be written as &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if&amp;nbsp; product not in ('auto','Cd') then output ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 16:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218655#M40297</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-25T16:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: IF clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218656#M40298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think the statement could be simplified by eliminating the output statement.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;that is,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;if product not in ('auto'&amp;nbsp; 'Cd')&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2015 19:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218656#M40298</guid>
      <dc:creator>yukclam9</dc:creator>
      <dc:date>2015-05-25T19:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: IF clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218657#M40299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I agree this a logic problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and De Morgan's Rules of conversion of negations are non-trivial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a program to help others understand nand and nor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Truth_Table" title="http://www.sascommunity.org/wiki/Truth_Table"&gt;Truth Table - sasCommunity&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ron Fehd&amp;nbsp; logical maven&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 19:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-clause/m-p/218657#M40299</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2015-05-26T19:15:36Z</dc:date>
    </item>
  </channel>
</rss>

