![]() Chapter Contents |
![]() Previous |
![]() Next |
| IF-THEN/ELSE |
| Valid: | in a DATA step |
| Category: | Control |
| Type: | Executable |
| Syntax | |
| Arguments | |
| Details | |
| Comparisons | |
| Examples | |
| See Also |
Syntax |
|
IF expression THEN statement;
<ELSE statement;> |
| Details |
| Comparisons |
| Examples |
These examples show different ways of specifying the IF-THEN/ELSE statement.
if x then delete;
if status='OK' and type=3 then count+1;
if age ne agecheck then delete;
if x=0 then if y ne 0 then put 'X ZERO, Y NONZERO'; else put 'X ZERO, Y ZERO'; else put 'X NONZERO';
if answer=9 then do; answer=.; put 'INVALID ANSWER FOR ' id=; end; else do; answer=answer10; valid+1; end;
data region; input city $ 1-30; if city='New York City' or city='Miami' then region='ATLANTIC COAST'; else if city='San Francisco' or city='Los Angeles' then region='PACIFIC COAST'; datalines; ...more data lines... ;
| See Also |
Statements:
|
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.