<?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: Multiple IF then statements query in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696447#M25272</link>
    <description>&lt;P&gt;Because the else if statement is only executed if the initial if statement is not true &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2020 11:37:13 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-11-04T11:37:13Z</dc:date>
    <item>
      <title>Multiple IF then statements query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696445#M25271</link>
      <description>&lt;P&gt;hello users !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the following SAS data set WORK.TOYS:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; Product &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Group&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Price&lt;BR /&gt;&amp;nbsp; --------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;----------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-----&lt;BR /&gt;&amp;nbsp; Cards &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Indoors&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.99&lt;BR /&gt;&amp;nbsp; Marbles&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Indoors&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.99&lt;BR /&gt;&amp;nbsp; Drum&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Instruments&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12.99&lt;BR /&gt;&amp;nbsp; Hula-Hoop&amp;nbsp; &amp;nbsp; &amp;nbsp;Outdoors&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12.99&lt;BR /&gt;&amp;nbsp; Ball&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Outdoors &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.49&lt;BR /&gt;&lt;BR /&gt;The following SAS program is submitted:&lt;/P&gt;
&lt;PRE id="yui_3_17_2_1_1604488319168_85"&gt;data WORK.GROUPS;
&amp;nbsp; &amp;nbsp;set WORK.TOYS;
&amp;nbsp; &amp;nbsp;if Group="Outdoors" then Price_Gp="C";
&amp;nbsp; &amp;nbsp;if Price ge 12.99 then Price_Gp="A";
&amp;nbsp; &amp;nbsp;else if Price ge 8.99 then Price_Gp="B";
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;What will be the value of Price_Gp for Hula-Hoop and Ball?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Answer is &lt;STRONG&gt;Hula-Hoop: 'A&lt;/STRONG&gt;',&amp;nbsp; Ball: 'C'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Why answer is not&amp;nbsp; &lt;STRONG&gt;Hula-Hoop: 'C&lt;/STRONG&gt;',&amp;nbsp; Ball: 'C ?? can pls someone help. Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 11:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696445#M25271</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-11-04T11:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple IF then statements query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696447#M25272</link>
      <description>&lt;P&gt;Because the else if statement is only executed if the initial if statement is not true &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 11:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696447#M25272</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-04T11:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple IF then statements query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696449#M25273</link>
      <description>&lt;P&gt;The line&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Price ge 12.99 then Price_Gp="A";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;executes and sets the Price_Gp value to "A" for Hula-Hoop. This overwrites the value of Price_Gp="C" that was obtained in the previous line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you don't want that, you need to make sure the above line does not execute for Hula-Hoop. This code would look like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.GROUPS;
   set WORK.TOYS;
   if Group="Outdoors" then Price_Gp="C";
   ELSE if Price ge 12.99 then Price_Gp="A";
   else if Price ge 8.99 then Price_Gp="B";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, for Outdoors toys, the lines that check the Price will not be used; and for toys that are not Outdoors, the price checks are the only lines that will be used.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 11:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696449#M25273</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-04T11:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple IF then statements query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696451#M25274</link>
      <description>It is overwrited by this :&lt;BR /&gt;if Price ge 12.99 then Price_Gp="A";</description>
      <pubDate>Wed, 04 Nov 2020 11:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-IF-then-statements-query/m-p/696451#M25274</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-11-04T11:48:33Z</dc:date>
    </item>
  </channel>
</rss>

