Previous Page | Next Page

Creating Subsets of Observations

Learning More

Comparison and logical operators

See Acting on Selected Observations and SAS Language Reference: Concepts.

DROP= and KEEP= data set options

Using the DROP= and KEEP= data set options to output a subset of variables to a SAS data set are discussed in Starting with SAS Data Sets.

FIRSTOBS= and OBS= data set options

Using these data set options to select observations from the beginning, middle, or end of a SAS data set are discussed in Starting with SAS Data Sets. They are documented completely in SAS Language Reference: Dictionary.

IF-THEN/ELSE, DELETE, and OUTPUT statements

The IF-THEN/ELSE, DELETE, and OUTPUT statements are completely documented in SAS Language Reference: Dictionary.

WHERE statement

See Producing Detail Reports with the PRINT Procedure. The WHERE statement selects observations based on a condition. Its action is similar to that of a subsetting IF statement. The WHERE statement is extremely useful in PROC steps, and it can also be useful in some DATA steps. The WHERE statement selects observations before they enter the program data vector (in contrast to the subsetting IF statement, which selects observations already in the program data vector).

Note:   In some cases, the same condition in a WHERE statement in the DATA step and in a subsetting IF statement produces different subsets. The difference is described in the discussion of the WHERE statement in SAS Language Reference: Dictionary. Be sure you understand the difference before you use the WHERE statement in the DATA step. With that caution in mind, a WHERE statement can increase the efficiency of the DATA step considerably.  [cautionend]

Previous Page | Next Page | Top of Page