Previous Page | Next Page

WHERE-Expression Processing

Deciding Whether to Use a WHERE Expression or a Subsetting IF Statement

To conditionally select observations from a SAS data set, you can use either a WHERE expression or a subsetting IF statement. While they both test a condition to determine whether SAS should process an observation, they differ as follows:

In most cases, you can use either method. However, the following table provides a list of tasks that require you to use a specific method:

Tasks Requiring Either WHERE Expression or Subsetting IF Statement
Task Method
Make the selection in a procedure without using a preceding DATA step WHERE expression
Take advantage of the efficiency available with an indexed data set WHERE expression
Use one of a group of special operators, such as BETWEEN-AND, CONTAINS, IS MISSING or IS NULL, LIKE, SAME-AND, and Sounds-Like WHERE expression
Base the selection on anything other than a variable value that already exists in a SAS data set. For example, you can select a value that is read from raw data, or a value that is calculated or assigned during the course of the DATA step subsetting IF
Make the selection at some point during a DATA step rather than at the beginning subsetting IF
Execute the selection conditionally subsetting IF

Previous Page | Next Page | Top of Page