SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2

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 if 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:

Table 12.5: 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

Категории