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?
HINT:
Specifying the filter condition using the IF statement. Note: the case IS sensitive within quotation.
SOLUTION:
Data Enrol;
Set Profile;
If Enrol = “Yes”;
Run;
*Note: The case IS sensitive within the quotation.
Enrol = “Yes” is different than
Enrol = “YES”
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |