SAS Institute. The Power to Know

Base SAS(R) 9.2 Guide to Information Maps

Previous Page | Next Page

SAS Data Set Options for the Information Maps Engine

FILTER= Data Set Option



Uses the filters that are defined in an information map to specify criteria in a query for subsetting a result set
Valid in: DATA Step
Category: Data Set Control
Restriction: Use only with information maps that contain filters
Restriction: Filters that prompt for values at run time are not supported

Syntax
Syntax Description
Details
Example

Syntax

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

Syntax Description

NOT operator

specifies that the inverse statement is true. The result of putting NOT in front of a quantity whose value is 0 (false) is 1 (true). That is, the result of negating a false statement is 1 (true).

For example, the following two expressions are equivalent, assuming that the filters are defined properly:

  • FILTER=30_and_under

  • FILTER=(NOT Over_30)

filter

specifies one or more filters in the information map. Parentheses can be used to specify precedence or groupings within the clause

The filter-n name is one that is created by SAS for use within the SAS session. Note that this name can different from the filter name that is within the information map. The filter names that are assigned by SAS conform to the SAS variable name rules that are specified in the VALIDVARNAME= system option. For more information on the VALIDVARNAME= system option, see the SAS Language Reference: Dictionary.

Requirement: If you specify more than a single filter, then parentheses are required.
Requirement: If you use a single filter, but the negation operator is added, then parentheses are required.
Boolean-operator

links sequences of comparisons in an expression. (Boolean operators are also known as logical operators.) The Boolean operators that you can use are AND, OR, or NOT. For more information about Boolean operators and expressions, see the SAS Language Reference: Concepts.

AND Operator

specifies that if both of the filters linked by AND are 1 (true), then the result of the AND operation is 1; otherwise, the result is 0. For example, in the following comparison the result is true (has a value of 1) only when the observation is for males over 30 years old:

FILTER=(Males AND Over_30)
OR operator

specifies that if either of the filters linked by OR is 1 (true), then the result of the OR operation is 1 (true); otherwise the OR operation produces a 0. For example, in the following comparison the result is true (has a value of 1) when the observation is for males or for subjects over 30 years old (or both):

FILTER=(Males OR Over_30)
Note: Filters are applied as data is retrieved from the corresponding data source, so using a filter restricts the amount of data that is read into the SAS session. In contrast, WHERE clauses are applied after data is retrieved from the source, so using a WHERE clause does not limit the amount of data that is read into the SAS session.

Details

Using the FILTER= option is similar to using a WHERE clause in a PROC SQL statement.

A filter contains criteria for subsetting data. An example of a filter is Males, which is defined in an information map as gender="Male" . Note that not all filters that are defined in an information map are supported by the Information Maps engine. You can use only filters that have static values assigned to them. (These are unprompted filters.) You can get a list of the filters that are supported by using the CONTENTS procedure with a libref that is created by the Information Maps engine and by using the information map name.

The rules of precedence for the Boolean operators follow the rules set for the SAS WHERE clause. These rules state that the NOT operator has the highest precedence, followed by the Boolean AND and Boolean OR operators. For more information about the rules for the SAS WHERE clause, see the topic about combining expressions using logical operators in the SAS Language Reference: Concepts.

When you use multiple filters, logical relationships between the filters must be defined. It is possible to have complex relationships between the filters by mixing the NOT, AND, and OR operators. Parentheses can be used to specify precedence or groupings within the clause.


Example

In the following example, there are three unprompted filters: Repeat Buyer, Midwest Region, and Southwest Region. These filters contain hard-coded values for implementing restrictions. Note the compound nature of the filter associations. The query 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;

Previous Page | Next Page | Top of Page