LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments:   To: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
In-Reply-To:   <C6A8364B-749E-4EDC-99CD-A43135F4475D@alumni.stanford.org>
Content-Type:   text/plain; charset="us-ascii"

Jack,

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 reduced.

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.

<end quote>

Mike Rhoads RhoadsM1@Westat.com

________________________________________ 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 To: SAS-L@LISTSERV.UGA.EDU Subject: Re: SELECT vs. IF/THEN ELSE

On Mar 21, 2009, at 8:35 pm, Arthur Tabachneck wrote:

> Orange, > > 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 > faster > 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. ===== <http://v8doc.sas.com/sashtml/lgref/z0201966.htm>

That statement is missing from the 9.1.3 and 9.2 documentation.

> > > Art > ------- > On Fri, 20 Mar 2009 13:20:07 -0400, help ly <help.ly2005@GMAIL.COM> > wrote: > >> Hi, >> >> There is a SAS base question that I am not sure of the answer is C >> or D. > I >> 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 >> for >> character variables. >> D. In the large amount selected data which is uniformly distributed >> for >> character variables. >> >> >> -- >> Thanks so much! >> >> Orange >> help.ly2005@gmail.com


Back to: Top of message | Previous page | Main SAS-L page