<?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 and else in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707270#M26481</link>
    <description>Thank you so much, Shmuel!</description>
    <pubDate>Sun, 20 Dec 2020 16:44:06 GMT</pubDate>
    <dc:creator>dooheekim01</dc:creator>
    <dc:date>2020-12-20T16:44:06Z</dc:date>
    <item>
      <title>If and else</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707234#M26472</link>
      <description>&lt;P&gt;The question :&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;create&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;results.output36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Ensure that all values for variable&amp;nbsp;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are between 40 and 200, inclusively.&lt;/LI&gt;&lt;LI&gt;If the value is missing or out of range, replace the value with the MEDIAN&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;value for the respective&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(A,B) calculated in step 2.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;The answer is :&lt;/P&gt;&lt;P&gt;data results.output36;&lt;BR /&gt;set cleandata36;&lt;BR /&gt;if Kilograms &amp;lt; 40 or Kilograms &amp;gt; 200 then do;&lt;BR /&gt;if group='A' then kilograms=79;&lt;BR /&gt;else kilograms=89;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is that:&lt;/P&gt;&lt;P&gt;if Kilograms &amp;lt;40 or Kilograms &amp;gt; 200 then do;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;else group='A' then kilograms=79;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;didn't work.&lt;/P&gt;&lt;P&gt;My question is why I should not use 'else' in red. It is hard to understand. Thank you so much for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Dec 2020 16:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707234#M26472</guid>
      <dc:creator>dooheekim01</dc:creator>
      <dc:date>2020-12-20T16:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: If and else</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707251#M26476</link>
      <description>&lt;P&gt;1) DO; needs to be closed by END;&lt;/P&gt;
&lt;P&gt;2) ELSE &amp;lt;do something&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Kilograms &amp;lt;40 or Kilograms &amp;gt; 200 then DO;
   /* option 1*/ &amp;lt;do something is optional&amp;gt;; END;
else /* 40 &amp;lt;= Kilograms &amp;lt;= 200 &amp;gt;
  group='A' ;  /* then needs to be preceded by IF*/
   kilograms=79; /* Is this part of the IF? of the ELSE? or always ? */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have more than one statement to do conditionally enclose then between DO: and END;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Dec 2020 08:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707251#M26476</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-12-20T08:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: If and else</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707270#M26481</link>
      <description>Thank you so much, Shmuel!</description>
      <pubDate>Sun, 20 Dec 2020 16:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707270#M26481</guid>
      <dc:creator>dooheekim01</dc:creator>
      <dc:date>2020-12-20T16:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: If and else</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707273#M26483</link>
      <description>&lt;PRE&gt;data result.output36;&lt;BR /&gt;set result.cleandata36;&lt;BR /&gt;if 40 &amp;lt;= kilograms le 200 then kilograms=kilograms;&lt;BR /&gt;else if group ='A' then kilograms=79;&lt;BR /&gt;else if group ="B" then kilograms=89;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;alternatively, you can code like above. 'then' for one action, 'do' for multiple actions and finish with 'end'.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Dec 2020 17:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707273#M26483</guid>
      <dc:creator>anming</dc:creator>
      <dc:date>2020-12-20T17:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: If and else</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707325#M26495</link>
      <description>Thank you so much, Anming. It was really helpful!</description>
      <pubDate>Sun, 20 Dec 2020 23:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-and-else/m-p/707325#M26495</guid>
      <dc:creator>dooheekim01</dc:creator>
      <dc:date>2020-12-20T23:37:52Z</dc:date>
    </item>
  </channel>
</rss>

