Introduction to SAS [12-19]

h

Subsetting Data Set

In some cases, you may want to filter the data set and keep only a subset of the original data. 

This can be done by using the IF statement.

The TEST data set above contains 3 observations: 2 Males and 1 Female.

Example

Data TEST3;
    Set Test;
    IF Gender = "Male";
Run;

The IF statement allows you to keep only the observations that meet the specified condition(s). 

In this example, only the "Male" observations are kept in the TEST3 data set. The "Female" observations are removed.

(Try it!)


Exercise

Create a new data set called ENROL based on the PROFILE data set. ENROL should contains only the patients enrolled in the study (ENROL = YES)

*The PROFILE data set should have been created in Introduction to SAS [10-19]. If you haven't done so, please go back and create the data set before working on this exercise.

Need some help?

Get Hint

Get Solution