Where Statement

Contents Index


The where statement can be used with any procedure to restrict the action of that procedure to observations satisfying the conditions of the where statement. Example:

proc means data=dumb;
where x<5 and y>3;
run;

Here proc means analyzes only the observations in the data set dumb for which x<5 and y>3.

Similar behavior can be obtained by using the where = data set option.

The where statement can be used in conjunction with the set statement to select observations from an existing data set. Here's an example.

Suppose the data set iris contains variables species and m1-m4. Then

data onetwo;
set iris;
where species=1 or species=2;
run;

creates a new data set onetwo containing the data for species 1 and species 2 only. The logical connecitives and and or can be used to create more complicated selection schemes.

The where statement provides more efficient processing than the subsetting if statement. SAS functions can NOT be used within the where statement, but are allowed in a subsetting if statement.


Contents Index

Copyright © 1997 by Jerry Alan Veeh. All rights reserved.