FILTER= Data Set Option

Uses the filters that are defined in an information map to specify criteria for subsetting a result set.
Valid in: DATA Step
Category: Data Set Control
Restrictions: Use only with information maps that contain filters.

Filters that prompt for values at run time are not supported.

Requirement: If you specify more than a single filter, then parentheses are required.

Syntax

FILTER=(<NOT> filter-1 <...Boolean-operator <NOT>filter-n>)

Required Argument

filter
specifies a filter that is applied when data is retrieved from the information map.
You must specify the names for filters that are assigned by SAS for use within the SAS session. The assigned names can differ from the filter names that are defined in the information map in that the assigned filter names conform to the rules for SAS variable names that are specified in the VALIDVARNAME= system option. For more information about the VALIDVARNAME= system option, see the SAS System Options: Reference. You can use the CONTENTS procedure to view the assigned filter names.

Optional Arguments

NOT
specifies that the inverse of the specified filter criteria is used to subset the data.
For example, if an information map contains a filter named Over_30 that is defined as age > 30, then specifying the data set option filter=(NOT Over_30) retrieves rows of data in which the AGE data item has a value of 30 or less.
Requirement:If you use the NOT operator with a single filter, then parentheses are required.
Boolean-operator
combines the effects of two filters or filter clauses.
AND specifies that data that satisfies the criteria defined in both filters or filter clauses is returned
OR specifies that data that specifies the criteria defined in either filter or filter clause is returned
For more information about Boolean operators and expressions, see SAS Language Reference: Concepts.

Details

A filter contains criteria for subsetting data. For example, a filter named Males could be defined in an information map as gender="Male".
An information map can contain filters that are not supported by the Information Maps engine. Only filters that are defined using static values (called unprompted filters) can be used in a FILTER= data set option. You can use the CONTENTS procedure to print a list of the filters that are supported by a libref that is created by the Information Maps engine.
Using the FILTER= data set option is similar to using a WHERE clause in a PROC SQL statement. However, filter criteria are applied as data is retrieved from the data source. As a result, a FILTER= option restricts the amount of data that is returned from the data source. In contrast, a WHERE clause is applied as data from the data source is brought into SAS. As a result, a WHERE clause does not restrict the amount of data that is retrieved.
When you specify more than one filter in the FILTER= option, you must use Boolean operators to define the logical relationships between the filters in the filter clause. The rules of precedence for Boolean operators in filter clauses follow the rules set for the SAS WHERE clause. These rules specify that the NOT operator has the highest precedence, followed by the AND and OR operators. You can use parentheses to specify explicit precedence or groupings within the clause. For more information about the rules for the SAS WHERE clause, see "Combining Expressions by Using Logical Operators" in SAS Language Reference: Concepts.

Example

In the following example, there are three unprompted filters: Repeat Buyer, Midwest Region, and Southwest Region. The retrieved data is filtered to produce new buyers from either the Midwest or Southwest regions.
option validvarname=any;  /* This option is needed for names with spaces */
libname Orion infomaps ...;
proc print data=Orion.'Star Schema'n
     (filter=( (NOT('Repeat Buyer'n) ) AND
               ( ('Midwest Region'n) OR 
                 ('Southwest Region'n) ) ) );
run;