|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|
> 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.
> if 1 = 2 then x = 33;
> else else else x=44 ;
> put x ;
> 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.
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 '- - - -';
* 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.