<?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: How If-then-else works in SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650136#M22339</link>
    <description>&lt;P&gt;Suppose you have a variable x, which holds numerical values.&lt;/P&gt;
&lt;P&gt;Both of these codes will yield the same result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x = 1 then y = 'A';
if x = 2 then y = 'B';
if x = 3 then y = 'C';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x = 1 then y = 'A';
else if x = 2 then y = 'B';
else if x = 3 then y = 'C';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the first code, all conditions will always be evaluated; in the second, if x equals 1, the second and third condition will not be evaluated, speeding up execution.&lt;/P&gt;
&lt;P&gt;By evaluating for the most frequent value first, and the least frequent last, you can further optimize your code.&lt;/P&gt;</description>
    <pubDate>Sun, 24 May 2020 06:25:11 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-05-24T06:25:11Z</dc:date>
    <item>
      <title>How If-then-else works in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650135#M22338</link>
      <description>&lt;P&gt;While learning sas tutorial from PSU.&lt;SPAN&gt;&amp;nbsp;@&lt;/SPAN&gt;&lt;CODE&gt;&lt;A href="https://online.stat.psu.edu/stat480/lesson/welcome-stat-480" target="_blank"&gt;https://online.stat.psu.edu/stat480/lesson/welcome-stat-480&lt;/A&gt;&lt;/CODE&gt;.&lt;/P&gt;&lt;P&gt;I Came across these sentences:&lt;/P&gt;&lt;P&gt;Note that, in general, using ELSE statements with IF-THEN statements can save resources:&lt;/P&gt;&lt;P&gt;Using IF-THEN statements without the ELSE statement causes SAS to evaluate all IF-THEN statements. Using IF-THEN statements with the ELSE statement causes SAS to execute IF-THEN statements until it encounters the first true statement. Subsequent IF-THEN statements are not evaluated.&lt;/P&gt;&lt;P&gt;can someone explain me the above lesson with an example. Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 24 May 2020 05:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650135#M22338</guid>
      <dc:creator>Hariharan1409</dc:creator>
      <dc:date>2020-05-24T05:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: How If-then-else works in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650136#M22339</link>
      <description>&lt;P&gt;Suppose you have a variable x, which holds numerical values.&lt;/P&gt;
&lt;P&gt;Both of these codes will yield the same result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x = 1 then y = 'A';
if x = 2 then y = 'B';
if x = 3 then y = 'C';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x = 1 then y = 'A';
else if x = 2 then y = 'B';
else if x = 3 then y = 'C';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the first code, all conditions will always be evaluated; in the second, if x equals 1, the second and third condition will not be evaluated, speeding up execution.&lt;/P&gt;
&lt;P&gt;By evaluating for the most frequent value first, and the least frequent last, you can further optimize your code.&lt;/P&gt;</description>
      <pubDate>Sun, 24 May 2020 06:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650136#M22339</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-24T06:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How If-then-else works in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650208#M22340</link>
      <description>&lt;P&gt;This means that if you write your IF/THEN/ELSE statements in the order of what you expect to happen most frequently it will be faster than if you ordered them in some other order.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 May 2020 18:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-If-then-else-works-in-SAS/m-p/650208#M22340</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-24T18:52:36Z</dc:date>
    </item>
  </channel>
</rss>

