<?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: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16820#M2392</link>
    <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I believe from a performance point of view the difference between "if then else" and "select when" is rather neglectable.&lt;BR /&gt;
&lt;BR /&gt;
The most important thing for both ways will be to order the cases descending according to probability (meaning: have the case which will be most often true first so all the other comparisons will be skipped).&lt;BR /&gt;
&lt;BR /&gt;
Also from a performance perspective: Things like reducing data volumes as early as possible, minimizing passes through data / full table scans, avoiding unnecessary sorting and minimizing disk I/O operations are much more relevant.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
    <pubDate>Sun, 19 Jun 2011 10:01:35 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2011-06-19T10:01:35Z</dc:date>
    <item>
      <title>The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16819#M2391</link>
      <description>* WEB PAGE :&lt;BR /&gt;
&lt;A href="http://web.utk.edu/sas/OnlineTutor/1.2/en/60477/m83/m83_11.htm" target="_blank"&gt;http://web.utk.edu/sas/OnlineTutor/1.2/en/60477/m83/m83_11.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
"Using DO Groups Efficiently"&lt;BR /&gt;
&lt;BR /&gt;
"Remember to use the following criteria when choosing which technique is&lt;BR /&gt;
more efficient"&lt;BR /&gt;
&lt;BR /&gt;
---------------------------------------------------------------------------&lt;BR /&gt;
                        | IF-THEN/ELSE Statements | SELECT/WHEN Statements |&lt;BR /&gt;
---------------------------------------------------------------------------&lt;BR /&gt;
The number of conditions| few                     | many                   |&lt;BR /&gt;
&lt;BR /&gt;
The distribution of a   | not uniform             | uniform                |&lt;BR /&gt;
variable's values&lt;BR /&gt;
&lt;BR /&gt;
The type of variable    | character               | numeric                |&lt;BR /&gt;
----------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I want to know the efficient difference of the IF-THEN/ELSE Statements and&lt;BR /&gt;
SELECT/WHEN Statements&lt;BR /&gt;
&lt;BR /&gt;
I tried to understand the efficient,but can't understand through SAS help.&lt;BR /&gt;
&lt;BR /&gt;
I want to know the description and example for the difference.</description>
      <pubDate>Sun, 19 Jun 2011 08:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16819#M2391</guid>
      <dc:creator>kk760105</dc:creator>
      <dc:date>2011-06-19T08:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16820#M2392</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I believe from a performance point of view the difference between "if then else" and "select when" is rather neglectable.&lt;BR /&gt;
&lt;BR /&gt;
The most important thing for both ways will be to order the cases descending according to probability (meaning: have the case which will be most often true first so all the other comparisons will be skipped).&lt;BR /&gt;
&lt;BR /&gt;
Also from a performance perspective: Things like reducing data volumes as early as possible, minimizing passes through data / full table scans, avoiding unnecessary sorting and minimizing disk I/O operations are much more relevant.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Sun, 19 Jun 2011 10:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16820#M2392</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-06-19T10:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16821#M2393</link>
      <description>Particularly, I want to know the efficient difference for the "The type of variable"&lt;BR /&gt;
(Character and Numeric)</description>
      <pubDate>Sun, 19 Jun 2011 14:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16821#M2393</guid>
      <dc:creator>kk760105</dc:creator>
      <dc:date>2011-06-19T14:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16822#M2394</link>
      <description>Hi,&lt;BR /&gt;
   IF/THEN/ELSE and/or SELECT/WHEN are frequently used for TABLE lookups. So instead of focussing on only those techniques (which are really about the same in terms of processing), perhaps you should broaden your investigation into a discussion of table lookup efficiencies and overall efficiencies:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2008/095-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/095-2008.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2007/042-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/042-2007.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/sgf09/336-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/sgf09/336-2009.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 19 Jun 2011 20:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16822#M2394</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-06-19T20:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16823#M2395</link>
      <description>Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
The same thread has been active on SAS-L the last couple of days.  Nat Wooding, as part of that thread, did an interesting comparison regarding the numeric vs character difference ( see: &lt;A href="http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1106c&amp;amp;L=sas-l&amp;amp;D=1&amp;amp;O=D&amp;amp;P=14099)" target="_blank"&gt;http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1106c&amp;amp;L=sas-l&amp;amp;D=1&amp;amp;O=D&amp;amp;P=14099)&lt;/A&gt;.&lt;BR /&gt;
&lt;BR /&gt;
Basically, if his tests were flawed, he showed that the difference does appear to be quite dramatic regarding character variables.  In those cases, it appears that the if-then scenario fares much better.&lt;BR /&gt;
&lt;BR /&gt;
Art&lt;BR /&gt;
---------&lt;BR /&gt;
&amp;gt; Hi,&lt;BR /&gt;
&amp;gt; IF/THEN/ELSE and/or SELECT/WHEN are frequently&lt;BR /&gt;
&amp;gt; used for TABLE lookups. So instead of focussing on&lt;BR /&gt;
&amp;gt; only those techniques (which are really about the&lt;BR /&gt;
&amp;gt; same in terms of processing), perhaps you should&lt;BR /&gt;
&amp;gt; broaden your investigation into a discussion of&lt;BR /&gt;
&amp;gt;  table lookup efficiencies and overall efficiencies:&lt;BR /&gt;
&amp;gt; ttp://www2.sas.com/proceedings/forum2008/095-2008.pdf&lt;BR /&gt;
&amp;gt; &lt;A href="http://www2.sas.com/proceedings/forum2007/042-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/042-2007.pdf&lt;/A&gt;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;A href="http://support.sas.com/resources/papers/sgf09/336-2009" target="_blank"&gt;http://support.sas.com/resources/papers/sgf09/336-2009&lt;/A&gt;&lt;BR /&gt;
&amp;gt; .pdf&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; ynthia</description>
      <pubDate>Sun, 19 Jun 2011 23:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16823#M2395</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-06-19T23:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16824#M2396</link>
      <description>Hi:&lt;BR /&gt;
  Interesting results -- as with anything to do with efficiency -- it depends on &lt;B&gt;your&lt;/B&gt; operating system, &lt;B&gt;your&lt;/B&gt; data and &lt;B&gt;your&lt;/B&gt; constraints, including programmer time for maintenance, etc. And whether you are optimizing for I/O, for CPU processing time, for clock time, for programmer maintenance time, or any number of factors. I always recommend that people run benchmarks with their data on their OS.&lt;BR /&gt;
 &lt;BR /&gt;
  Nat provides a good example of pumping data through a program to generate benchmarking results. The next step would be to run a typical program using test data or a subset of the real data -- one with SELECT/WHEN and one with IF/THEN/ELSE or other TABLE lookup techniques (such as PROC FORMAT or hash table)  to compare the performance of the real data to that of the benchmark with fake data.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 20 Jun 2011 01:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16824#M2396</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-06-20T01:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16825#M2397</link>
      <description>Thank you, your kind words !!&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But, I don't know the fundamental reason.&lt;BR /&gt;
&lt;BR /&gt;
1. Why are the diffrent for the Character and Numeric variable between IF/ELSE&lt;BR /&gt;
   and Select statement?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
2. Why are the diffrent for The distribution of variable's values between IF/ELSE&lt;BR /&gt;
   and Select statement?&lt;BR /&gt;
   &lt;BR /&gt;
3. Why are the diffrent for the number of conditions between IF/ELSE&lt;BR /&gt;
   and Select statement?

Message was edited by: kk760105</description>
      <pubDate>Mon, 20 Jun 2011 02:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16825#M2397</guid>
      <dc:creator>kk760105</dc:creator>
      <dc:date>2011-06-20T02:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16826#M2398</link>
      <description>I remembered that Arther.Carpenter has written a papa about this question before. He prefer to use select/when which is more efficient then if/else, Especially when you use expression in () of when not in select .Such as : select(); when(sex='F') .... when(sex='M')....&lt;BR /&gt;
Certainly, Hope Art.C can write some words to explain this situation more.&lt;BR /&gt;
Art.C is here now? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 20 Jun 2011 07:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16826#M2398</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-20T07:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: The efficient difference of the IF-THEN/ELSE Statements and SELECT/WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16827#M2399</link>
      <description>Thank you for the confidence Ksharp, but I suspect those may have been someone else's recommendations.  Bob Virgle did a fair number of tests on these statements in his efficiencies book a number of years ago.  And while I did write about the relative efficiencies in the narrow context of performing table look ups.  I would defer to Cynthia's comment that you need to know your data, your machine, your situation.  That said I find the differences between the comparisons on numerics and characters to be very interesting and probably worthy of more research.</description>
      <pubDate>Tue, 21 Jun 2011 05:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-efficient-difference-of-the-IF-THEN-ELSE-Statements-and/m-p/16827#M2399</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-21T05:54:10Z</dc:date>
    </item>
  </channel>
</rss>

