Previous Page | Next Page

Creating Subsets of Observations

Review of SAS Tools


Statements

DATA <libref-1.>SAS-data-set-1< . . .<libref-n.>SAS-data-set-n>;

names the SAS data set(s) to be created in the DATA step.

DELETE;

deletes the current observation. The DELETE statement is usually used as part of an IF-THEN/ELSE group.

IF condition;

tests whether the condition is true. If it is true, then SAS continues processing the current observation; if it is not true, then SAS stops processing the observation, does not add it to the SAS data set, and returns to the top of the DATA step. The conditions used are the same as in the IF-THEN/ELSE statements. This type of IF statement is called a subsetting IF statement because it produces a subset of the original observations.

OUTPUT <SAS data set>;

immediately writes the current observation to the SAS data set. The observation remains in the program data vector, and you can continue programming with it, including outputting it again if you desire. When an OUTPUT statement appears in a DATA step, SAS does not automatically output observations to the SAS data set; you must specify the destination for all output in the DATA step with OUTPUT statements. Any SAS data set that you specify in an OUTPUT statement must also appear in the DATA statement.

Previous Page | Next Page | Top of Page