Reading Hierarchical Files |
Creating One Observation per Detail
Record |
Conditionally Executing SAS Statements
You can use the value of |
data perm.people; infile census; retain Address; input type $1. @; |
|
You can then direct SAS software to perform a given task based on a specific condition using an IF-THEN statement. |
General form, IF-THEN statement:
where expression is any valid SAS expression and statement is any executable SAS statement. |
IF-THEN statements are used to define conditions and actions. If
a condition (defined by a SAS expression) is met,
then an action (defined by an executable SAS statement)
takes place.
Expressions in conditional statements usually involve some kind of comparison.
In the following example,
The expression defines a condition so that when the value of
data perm.people; infile census; retain Address; input type $1. @; if type='H' then input @3 Address $15.; |
When you are comparing values, it is important to make sure that the
values are expressed exactly as they are coded in the data. For example,
the expression below would be evaluated as false because the values in the
data are stored in uppercase letters.
if type='h' then ... ; |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.