|SAS Data Set Options|
|Valid in:||DATA step and PROC steps|
|Restriction:||Cannot be used with the POINT= option in the SET and MODIFY statements.|
|Example 1: Selecting Observations from an Input Data Set|
|Example 2: Selecting Observations from an Output Data Set|
is an arithmetic or logical expression that consists of a sequence of operators, operands, and SAS functions. An operand is a variable, a SAS function, or a constant. An operator is a symbol that requests a comparison, logical operation, or arithmetic calculation. The expression must be enclosed in parentheses.
Use the WHERE= data set option with an input data set to select observations that meet the condition specified in the WHERE expression before SAS brings them into the DATA or PROC step for processing. Selecting observations that meet the conditions of the WHERE expression is the first operation SAS performs in each iteration of the DATA step.
You can also select observations that are written to an output data set. In general, selecting observations at the point of input is more efficient than selecting them at the point of output. However, there are some cases when selecting observations at the point of input is not practical or not possible.
You can apply OBS= and FIRSTOBS= processing to WHERE processing. For more information see Processing a Segment of Data That is Conditionally Selected in SAS Language Reference: Concepts.
If you use both the WHERE= data set option and the WHERE statement in the same DATA step, SAS ignores the WHERE statement for data sets with the WHERE= data set option. However, you can use the WHERE= data set option with the WHERE command in SAS/FSP software.
Note: Using indexed SAS data sets can improve performance significantly when you are using WHERE expressions to access a subset of the observations in a SAS data set. See Understanding SAS Indexes in SAS Language Reference: Concepts for a complete discussion of WHERE expression processing with indexed data sets and a list of guidelines to consider before indexing your SAS data sets.
WHERE-Expression Processing in SAS Language Reference: Concepts