The IF-THEN/ELSE
statement executes a statement or group of statements based on a condition
that you specify.
IF expression THEN statement;
|
If
expression is true, then SAS executes
the statement in the THEN clause. If the
expression
is false and if an ELSE statement is present, then SAS executes the ELSE statement.
The statement following THEN and ELSE can be either a single SAS statement
(including an IF-THEN/ELSE statement) or a DO group.
For example:
if (exist(table)) then
_msg_='SAS table already exists.';
else do;
call new(table,'',1,'y');
_msg_='Table has been created.';
end;
Suppose your application is designed to run in batch
mode and you do not want to generate any messages. You could use a null statement
after THEN:
if (exist(table)) then;
else call new(table,'',1,'y');
For more information, refer to
SAS Language Reference: Dictionary.
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.