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 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 Mar 2009 14:41:52 -0400
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: SELECT vs. IF/THEN ELSE

I'd say, in none of them. C and D are typical answers for something which has to do with subsetting data. To be true, I even don't know the difference of randomly and uniformly, that's nearly the same for me. Might have a reason in my bad english knowledge. However, IF-THEN-ELSE and SELECT are branch statements. IF-THEN-ELSE is a branch wich goes in exactly two directions, select can have more than 2 directions. select is realized in 2 forms in SAS which are different. One of them is a kind of CASE-construct. It has 2 branches like IF-ELSE, but one of them contains a list of constants which are all compared with "=" with one single variable. One of the conditions is true and the others are not tested any more. If all are false the other (else) branche is choosen. Another form is, you can use different conditions with different variables (a list of conditions instead a list of constants). All of that conditions are tested. (A kind of OR) With IF, all the conditions must be combined with logical operators "and, or, not" or you have to build nested constructs. That is sometimes hard to read and hard to find errors in. So SELECT might help to make it more readable. Both constructs don't have much to do with the dataset and randomly or not randomly distributed values. Every obs is pumped through that statements, no matter were the values are. The only thing of less or more efficiency might be the so called "short circuit evaluation". If you have a logical expression with some combined conditions, it might be good to put the least probable condition in a AND-chain at the beginning. If the first cond. is false, the others must not be tested... A optimizer cannot know what data will come, but you might have a idea.

Gerhard

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