<?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 statement in data step in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216551#M53328</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simple Q:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it should be &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;if (Age NE 16) &lt;STRONG&gt;and&lt;/STRONG&gt; (Age NE 15) then Group=1; else Group=2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;if age=15&amp;nbsp; or if age=16 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;the condition :"&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;(Age NE 16) or (Age NE 15) " will be true .&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;Xia Keshan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 May 2015 14:27:07 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-05-18T14:27:07Z</dc:date>
    <item>
      <title>If statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216549#M53326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;I'm preparing for SAS base certification and I require some clarification regarding the below question. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Data Step&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Data work.Test; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Infile ‘c:\class1.csv’ dsd; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Input Name $ Sex $ Age Height; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;If Age NE 16 and Age NE 15 then Group = 1; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Else Group = 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Q Which of the following assignment statements for variable group are functionally equivalent to the original statement used in the above data step?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; Below are 2 of the answers give. The &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;correct answer is answer B&lt;/STRONG&gt;&lt;/SPAN&gt;. I understand why answer B is correct. However can someone please explain why answer A is wrong? My argument is a person can't have 2 age values, therefore answer A should work too.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;A) if (Age NE 16) or (Age NE 15) then Group=1; else Group=2;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B) if Age not in(15,16) then Group=1; else Group=2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Any help regarding this is appreciated. Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 14:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216549#M53326</guid>
      <dc:creator>YasodaJ</dc:creator>
      <dc:date>2015-05-18T14:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216550#M53327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah yes.&amp;nbsp; Its actually so subtle I didn't see it on a first read through.&amp;nbsp; They have switched the logic gate in A:&lt;/P&gt;&lt;P&gt;If Age=16, then the logic:&lt;/P&gt;&lt;P&gt;(age ne 16)=0, (age ne 15)=1 therefore 0 or 1 =1&lt;/P&gt;&lt;P&gt;If age=15 then:&lt;/P&gt;&lt;P&gt;(age ne 16)=1, (age ne 15)=0 therefore 1 or 0 =1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the original code:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;If Age=16, then the logic:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;age ne 16=0, age ne 1=1 therefore 0 and 1 =0&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;If age=15 then:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;age ne 16=1, age ne 15=0 therefore 1 and 0 =0&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;You see the switch from the and to the or reverses the result.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Plus the fact that in() reads easier and is expandable.&amp;nbsp; And the original is two tests, the in() is one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 14:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216550#M53327</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-18T14:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216551#M53328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simple Q:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it should be &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;if (Age NE 16) &lt;STRONG&gt;and&lt;/STRONG&gt; (Age NE 15) then Group=1; else Group=2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;if age=15&amp;nbsp; or if age=16 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;the condition :"&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;(Age NE 16) or (Age NE 15) " will be true .&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;Xia Keshan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 14:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216551#M53328</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-18T14:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216552#M53329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;A) if (Age NE 16) or (Age NE 15)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;is always true. If a person's age is 15, the first half is true, if 16, the second half is true, and with all other ages both parts are true. group will always be set to 1.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 15:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216552#M53329</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-05-18T15:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216553#M53330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for the prompt replies &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 09:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-statement-in-data-step/m-p/216553#M53330</guid>
      <dc:creator>YasodaJ</dc:creator>
      <dc:date>2015-05-21T09:11:29Z</dc:date>
    </item>
  </channel>
</rss>

