|Date: ||Sun, 22 Mar 2009 08:57:38 -0400|
|Reply-To: ||Mike Rhoads <RHOADSM1@WESTAT.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Mike Rhoads <RHOADSM1@WESTAT.COM>|
|Subject: ||Re: SELECT vs. IF/THEN ELSE|
|Content-Type: ||text/plain; charset="us-ascii"|
Funny you should mention that point in the 8.2 doc, as I just happened to run into the following Problem Note yesterday (http://support.sas.com/kb/10/197.html).
Problem Note 10197: Documentation incorrect about differences with SELECT group and IF-THEN/ELSE statements
The SAS Language Reference: Dictionary, Version 8 incorrectly states:
When you have a long series of mutually exclusive
conditions, using a SELECT group is more efficient than
using a series of IF-THEN statements because CPU time is
The CPU time is equivalent as long as the conditions are put in the
same order with each statement.
The documentation is corrected beginning in SAS 9.1.
From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jack Hamilton [jfh@STANFORDALUMNI.ORG]
Sent: Sunday, March 22, 2009 12:44 AM
Subject: Re: SELECT vs. IF/THEN ELSE
On Mar 21, 2009, at 8:35 pm, Arthur Tabachneck wrote:
> I'd like to see the other two options (i.e., a and b).
> While I agree with my colleagues, I did run some tests on one
> interpretation of random vs uniformly distributed character
> variables, on
> a file that had a million records but only two distinct values.
> In those tests, regardless of distribution, if-then-else ALWAYS ran
> then the equivalent select statement.
This is a puzzlement. I recall having read, once long ago and far
away, that a SELECT is converted to an IF-THEN-ELSE internally, so the
execution time should be the same (compilation time might be different).
I can't find that statement now - but since the latest improvement to
the organization of the SAS support web pages, I have a hard time
finding anything, so it might still be there somewhere.
The SAS 8.2 documentation says:
When you have a long series of mutually exclusive conditions, using a
SELECT group is more efficient than using a series of IF-THEN
statements because CPU time is reduced. Large numbers of conditions
make a SELECT group more efficient than IF-THEN/ELSE statements
because CPU time is reduced. SELECT groups also make the program
easier to read and debug.
That statement is missing from the 9.1.3 and 9.2 documentation.
> On Fri, 20 Mar 2009 13:20:07 -0400, help ly <help.ly2005@GMAIL.COM>
>> There is a SAS base question that I am not sure of the answer is C
>> or D.
>> prefer the answer of D. Anyone has any opinion on this?
>> 1. In which situation, SELECT is more efficient than IF/THEN ELSE?
>> C. In the large amount selected data which is randomly distributed
>> character variables.
>> D. In the large amount selected data which is uniformly distributed
>> character variables.
>> Thanks so much!