<?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: else if in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335837#M76066</link>
    <description>&lt;P&gt;The statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if level = 2 or 3 then expertise =' Medium';&lt;/P&gt;
&lt;P&gt;does NOT mean&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else if level=2 or level=3 then expertise='Medium':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's because the clause "or 3"&amp;nbsp;&amp;nbsp; is really a logical expression&amp;nbsp;"or [some condition not=0]".&amp;nbsp;&amp;nbsp;&amp;nbsp; Only zero is false, so 3 must ALWAYS be true.&amp;nbsp; As a result the "medium" ends up getting everything the failed the prior 2 IF tests.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else if level in (2,3) then expertise='Medium';&lt;/P&gt;</description>
    <pubDate>Sat, 25 Feb 2017 08:29:09 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-02-25T08:29:09Z</dc:date>
    <item>
      <title>else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335829#M76062</link>
      <description>&lt;P&gt;Obsname level :&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Frank 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Joan 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Sui 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jose 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Burt 4&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Kelly .&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Juan 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following SAS program is submitted:&lt;/P&gt;&lt;P&gt;&amp;nbsp;data work . expertise;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set work. levels;&lt;/P&gt;&lt;P&gt;&amp;nbsp;if level = . then expertise = 'Unknown';&lt;/P&gt;&lt;P&gt;&amp;nbsp;else if level = 1 then expertise = 'Low';&lt;/P&gt;&lt;P&gt;&amp;nbsp;else if level = 2 or 3 then expertise =' Medium';&lt;/P&gt;&lt;P&gt;&amp;nbsp;else expertise = 'High';&lt;/P&gt;&lt;P&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Which of the following values does the variable EXPERTISE contain?&lt;BR /&gt;&lt;BR /&gt;A. Low, Medium, and High only&lt;BR /&gt;B. Low, Medium, and Unknown only&lt;BR /&gt;C. Low, Medium, High, and Unknown only&lt;BR /&gt;D. Low, Medium, High, Unknown, and ' ' (missing character value)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with its answer with a reasoning&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2017 08:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335829#M76062</guid>
      <dc:creator>nish1017</dc:creator>
      <dc:date>2017-02-25T08:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335830#M76063</link>
      <description>&lt;P&gt;Do you have SAS?&amp;nbsp; Why not run a program and see?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2017 07:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335830#M76063</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-25T07:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335834#M76064</link>
      <description>&lt;P&gt;I have, but somehow not getting the logic. Just want to know why expertise level of 'High' wont come, as there is clearly a level of 4 stated in this problem. This was one of the questions posted on the forums earlier, but didnt find a convincing answer there. Would be great if you can help me understand the logic. Specifically I am stuck as to why the else if&amp;nbsp;NOT generate&amp;nbsp;'High' as an output in the problem.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2017 08:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335834#M76064</guid>
      <dc:creator>nish1017</dc:creator>
      <dc:date>2017-02-25T08:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335837#M76066</link>
      <description>&lt;P&gt;The statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else if level = 2 or 3 then expertise =' Medium';&lt;/P&gt;
&lt;P&gt;does NOT mean&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else if level=2 or level=3 then expertise='Medium':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's because the clause "or 3"&amp;nbsp;&amp;nbsp; is really a logical expression&amp;nbsp;"or [some condition not=0]".&amp;nbsp;&amp;nbsp;&amp;nbsp; Only zero is false, so 3 must ALWAYS be true.&amp;nbsp; As a result the "medium" ends up getting everything the failed the prior 2 IF tests.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; else if level in (2,3) then expertise='Medium';&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2017 08:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335837#M76066</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-25T08:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335839#M76067</link>
      <description>&lt;P&gt;I didn't run the code myself buy this looks suspicious:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; else if level = 2 or 3 then expertise =' Medium';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That is not the same as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (level=2 or level=3)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What SAS sees is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if 3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is always true. So the else after that is never executed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2017 14:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335839#M76067</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-02-25T14:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335865#M76073</link>
      <description>I got it ! I was considering it as&lt;BR /&gt;if (level=2 or level=3) WHICH is not the case. I got this thing clear now .</description>
      <pubDate>Sat, 25 Feb 2017 16:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335865#M76073</guid>
      <dc:creator>nish1017</dc:creator>
      <dc:date>2017-02-25T16:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: else if</title>
      <link>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335866#M76074</link>
      <description>Thanks jklaverstijn. I mixed up exactly in the thing you pointed out/</description>
      <pubDate>Sat, 25 Feb 2017 16:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/else-if/m-p/335866#M76074</guid>
      <dc:creator>nish1017</dc:creator>
      <dc:date>2017-02-25T16:06:31Z</dc:date>
    </item>
  </channel>
</rss>

