Filter Data Task

About the Filter Data Task

The Filter Data task enables you to quickly create a basic filter to subset your input data source.

Example 1: Creating a Simple Filter

This example creates an output data set that contains salaries less than $750,000.
  1. In the Tasks section, expand the Data folder and double-click Filter Data. The user interface for the Filter Data task opens.
  2. For the input data source, select SASHELP.BASEBALL.
  3. Assign Salary to the Variable 1 role.
  4. From the Comparison drop-down list, select Less than.
  5. From the Value type drop-down list, select Enter a value.
  6. In the Value box, enter 750.
  7. Under the Output Data Set heading, select Show output data to view the output data set in the results. From the Show drop-down list, select Show all output data.
  8. To run the task, click Submit SAS Code.
Here is a subset of the results, which lists the players who have a salary less than $750,000.
Filtered Data Set—WORK.filter

Example 2: Creating a Compound Filter

This example creates an output data set of all the players who earn less than $750,000 and who are in the American League.
  1. In the Tasks section, expand the Data folder and double-click Filter Data. The user interface for the Filter Data task opens.
  2. For the input data source, select SASHELP.BASEBALL.
  3. To create the filter for salaries less than $750,000:
    1. Under the Filter 1 heading, assign Salary to the Variable 1 role.
    2. From the Comparison drop-down list, select Less than.
    3. From the Value type drop-down list, select Enter a value.
    4. In the Value box, enter 750.
    5. From the Logical drop-down list, select AND.
    6. To create the filter for players in the American League:
      1. Under the Filter 2 heading, assign League to the Variable 2 role.
      2. From the Comparison drop-down list, select Equal.
      3. From the Value type drop-down list, select Select distinct value.
      4. From the Value drop-down list, select American.
  4. Under the Output Data Set heading, select Show output data to view the output data set in the results. From the Show drop-down list, select Show all output data.
  5. To run the task, click Submit SAS Code.
Here is a subset of the results, which shows all the players in the American League who have a salary less than $750,000.
WORK.Filter Data Set

Creating Your Filter

To create a filter for the input data source:
  1. In the Tasks section, expand the Data folder and double-click Filter Data. The user interface for the Filter Data task opens.
  2. Select an input data source.
  3. In the Variable 1 box, select the variable that you want to use in the filter.
  4. From the Comparison drop-down list, select the comparison operator. The default value is Less than.
  5. From the Value type drop-down list, choose one of these options:
    • Enter value specifies that you want to enter a value in the Value box.
    • Select distinct value specifies that you want to select a value from the input data source. The Value drop-down list shows the first 100 unique values for that column.
    • Enter a percentile specifies that you want to enter a percentage in the Value box.
  6. To create a compound filter, select a value from the Logical drop-down list. Then specify the values for Filter 2.
  7. To specify a name for the output data set, expand Output Data Set and enter the name for the output data set in the Data box. To view the output data in the results, select Show output data. You can choose to view a subset or all of the data.