LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (July 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
=========================================================================  
Date:   Fri, 19 Jul 2002 09:23:54 -0400
Reply-To:   "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject:   Re: Else else else and if if if
Content-Type:   text/plain

> From: Ace [mailto:b.rogers@VIRGIN.NET] > Found a wierd 'undocumented feature' in SAS - reapeating the word > 'else' dont't generate any error or even warning statements. > > data; > if 1 = 2 then x = 33; > else else else x=44 ; > put x ; > run; > > runs absolutely fine in V6 & 8, windows & unix.

for the record runs in v9, too.

see also the recommended optimization: SAS Programming tips:a Guide to Efficient SAS Processing Tip 5.13: Use a series of conditions 'When a statement contains a large number of conditions, use a series of IF-THEN clauses rather than a compound expression with AND.'

AND: evaluates all conditions even if one is false IF-THEN: stops evaluating the series as soon as one clause is false, thus saving evaluation thru the rest of the series. which will save those ever so valuable CPU cycles, especially on many test, and many obs.

data _NULL_; infile cards; input X Y; if X=1 and y=2 then put 'and ' X= Y=; else put 'else: and ' X= Y=;

if X=1 then if Y=3 then put 'double if ' X= Y=; else put 'else: double if ' X= Y=; put '- - - -'; cards; 1 2 1 3 1 4 ;run;

* SQL stops evaluating either of the above constructs when it meets the first false condition.

Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov

OpSys: Win_Pro Ver: 9.000000000

--> cheerful provider of TESTED SAS code from the Clue?Gee!Wrx <--

If you always try to be logical, you probably won't ever have much sorrow, or much fun.


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