Previous Page | Next Page

Conditionally Processing Observations from Multiple SAS Data Sets

Review of SAS Tools


Statements

IF condition;

tests whether the condition is true. If it is true, then SAS continues processing the current observation; if it is false, then SAS stops processing the observation and returns to the beginning of the DATA step. This type of IF statement is called a subsetting IF statement because it produces a subset of the original observations.

IF condition THEN action;
<ELSE action;>

tests whether the condition is true; if so, then the action in the THEN clause is executed. If the condition is false and an ELSE statement is present, then the ELSE action is executed. If the condition is false and no ELSE statement is present, then execution proceeds to the next statement in the DATA step.

SET SAS-data-set (IN=variable) SAS-data-set-list;

creates a variable that is associated with a SAS data set. The value of variable is 1 if the data set has contributed to the observation currently in the program data vector; 0 if it has not. The IN= variable exists only while the DATA step executes; it is not written to the output data set.

You can use the option with any data set that you name in the SET, MERGE, MODIFY, or UPDATE statement, but use a different variable name for each one.

SET SAS-data-set-list END=variable;

creates a variable whose value is 0 until the DATA step starts to process its last observation. When processing of the last observation begins, the value of variable changes to 1. The END= variable exists only while the DATA step executes; it is not written to the output data set.

You can also use the END= option with the MERGE, MODIFY, and UPDATE statements.

Previous Page | Next Page | Top of Page