Use the READ Statement with the WHERE Clause

Use the WHERE clause to conditionally select observations from within the specified range. The following statements create a matrix to contain the variables Age, Height, and Weight for females in the Sashelp.Class data set:

use Sashelp.Class;
read all var _num_ into Female where(sex="F");
print Female;

Figure 7.13: Female Students

Female
13 56.5 84
13 65.3 98
14 62.8 102.5
12 59.8 84.5
15 62.5 112.5
11 51.3 50.5
14 64.3 90
12 56.3 77
15 66.5 112


The section Process Data by Using the WHERE Clause describes other features of the WHERE clause. For example, you can create a matrix to contain the student names that begin with the letter J, by using the following statements:

read all var {Name} into J where(name=:"J");
print J;

Figure 7.14: Names That Begin with the Letter J

J
James
Jane
Janet
Jeffrey
John
Joyce
Judy