<?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: SAS IF ELSE - I don't understand the answer to this in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625095#M184220</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312354"&gt;@pri26&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you execute the code step by step:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;first, amount is set to 7&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.24.54.png" style="width: 62px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36150i5A63AC83DA5C1745/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.24.54.png" alt="Capture d’écran 2020-02-16 à 10.24.54.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Then SAS checks the IF condition:
&lt;UL&gt;
&lt;LI&gt;if amount = 5 then word = "CAT"; &lt;FONT color="#FF0000"&gt;FALSE&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;else if amount = 7 then word = "DOG"; &lt;FONT color="#339966"&gt;TRUE -&amp;gt; so the value of word is set to 'DOG'&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;else word = "NoNE !!!";&amp;nbsp;&lt;FONT color="#FF0000"&gt;FALSE&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.25.10.png" style="width: 109px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36151iDC0848CE26FB10C0/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.25.10.png" alt="Capture d’écran 2020-02-16 à 10.25.10.png" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT color="#000000"&gt;Finally, the value of amount is set to 5:&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.25.19.png" style="width: 97px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36152i12E053852C13E180/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.25.19.png" alt="Capture d’écran 2020-02-16 à 10.25.19.png" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NB: it would have been better to have a LENGTH statement to define the word variable. As it is missing here, the length is set by default to 3, as it is the length of the first value proposed for this variable in the IF condition ('CAT'). It doesn't matter here as 'DOG' has the same number of letters than 'CAT'. But you can test to set amount to 3 for example, you will see that the 'ELSE' statement is true and that is displays 'NoN' and not 'NoNE !!!'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
    <pubDate>Sun, 16 Feb 2020 09:34:56 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-02-16T09:34:56Z</dc:date>
    <item>
      <title>SAS IF ELSE - I don't understand the answer to this</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625086#M184217</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-02-16 at 10.04.39 PM.png" style="width: 364px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36149iEAC579EC2F27A162/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-02-16 at 10.04.39 PM.png" alt="Screen Shot 2020-02-16 at 10.04.39 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I don't understand why the answer to this is a and not b?&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 09:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625086#M184217</guid>
      <dc:creator>pri26</dc:creator>
      <dc:date>2020-02-16T09:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IF ELSE - I don't understand the answer to this</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625091#M184219</link>
      <description>&lt;P&gt;WORD is set when AMOUNT=7.&lt;/P&gt;
&lt;P&gt;It is not reset when AMOUNT changes.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 09:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625091#M184219</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-16T09:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IF ELSE - I don't understand the answer to this</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625095#M184220</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312354"&gt;@pri26&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you execute the code step by step:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;first, amount is set to 7&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.24.54.png" style="width: 62px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36150i5A63AC83DA5C1745/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.24.54.png" alt="Capture d’écran 2020-02-16 à 10.24.54.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Then SAS checks the IF condition:
&lt;UL&gt;
&lt;LI&gt;if amount = 5 then word = "CAT"; &lt;FONT color="#FF0000"&gt;FALSE&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;else if amount = 7 then word = "DOG"; &lt;FONT color="#339966"&gt;TRUE -&amp;gt; so the value of word is set to 'DOG'&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;else word = "NoNE !!!";&amp;nbsp;&lt;FONT color="#FF0000"&gt;FALSE&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.25.10.png" style="width: 109px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36151iDC0848CE26FB10C0/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.25.10.png" alt="Capture d’écran 2020-02-16 à 10.25.10.png" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT color="#000000"&gt;Finally, the value of amount is set to 5:&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.25.19.png" style="width: 97px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36152i12E053852C13E180/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.25.19.png" alt="Capture d’écran 2020-02-16 à 10.25.19.png" /&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NB: it would have been better to have a LENGTH statement to define the word variable. As it is missing here, the length is set by default to 3, as it is the length of the first value proposed for this variable in the IF condition ('CAT'). It doesn't matter here as 'DOG' has the same number of letters than 'CAT'. But you can test to set amount to 3 for example, you will see that the 'ELSE' statement is true and that is displays 'NoN' and not 'NoNE !!!'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 09:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-IF-ELSE-I-don-t-understand-the-answer-to-this/m-p/625095#M184220</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-16T09:34:56Z</dc:date>
    </item>
  </channel>
</rss>

