Working with SAS Data Sets |
Use the WHERE clause as you did with the LIST statement, to conditionally select observations from within the specified range. If you want to create a matrix FEMALE containing the variables AGE, HEIGHT, and WEIGHT for females only, use the following statements:
> read all var _num_ into female where(sex="F"); > print female; FEMALE 11 51.3 50.5 12 59.8 84.5 12 56.3 77 13 56.5 84 13 65.3 98 14 62.8 102.5 14 64.3 90 15 62.5 112.5 15 66.5 112Now try some special features of the WHERE clause to find values that begin with certain characters (the =: operator) or that contain certain strings (the ? operator). To create a matrix
> read all var{name} into j where(name=:"J"); > print j; J JOYCE JAMES JANE JOHN JEFFREY JUDY JANETTo create a matrix
> read all var{name} into al where(name?"AL"); > print al; AL ALICE ALFRED RONALD
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.