An official website of the United States government
Skip Navigation

Using Correct Full Boolean Logic to Build a Selection Statement

left-img

In SEER*Stat, the lines of a statement are evaluated in order from top to bottom. 

These 4 lines are AND'd together to form the text at the bottom. When being evaluated to determine which records to include, first all records that are for "All Sites" are selected. Then from those records, only those records with a Behavior of "Malignant" are kept. And so on in order down the list. 

If you want to override this order of precedence, you can group one or more lines together by enclosing them in a group (parentheses). The grouped lines will be evaluated on their own as a single True or False statement.

Example

Suppose you want to create a selection statement that will select all males that are either white or black. A common mistake is to create the following:

Incorrect:

This will actually select all records with Sex as Male. From those records it will select those records with Race equal to Black. Then from those records it tries to find Race equal to White. But that last part will find no entries. 

The best way to express the selection criteria you want is as follows:

Correct:

The second line in the above selection statement will be satisfied by any record for which the value of the "Race recode" variable matches any of the comma-separated values on the line -- namely, "White" or "Black".

Here is another way to achieve the same results, using the "And" and "Or" conjunctions and groups:

Correct:

Notice that this statement looks just like the original, incorrect statement, except that the last two lines are grouped by parentheses. This grouping gives them precedence, so that the expression inside the group (Race = 'White' Or Race = 'Black') is evaluated first, and the result is used to complete the "And" expression.

Another Example

For the session, the user wants to select all reportable cancers, and for Colon and Rectum only include Malignant records. The user set up the selection statement like this:

Incorrect:

This is incorrect because all of the records will be returned with a Behavior Code of "Benign", "Borderline Malignancy", "In Situ", or "Malignancy". The grouping does nothing because it is trying to include records which are already present. 

Correct:

This statement correctly includes records with a Behavior Code of "Benign", "Borderline Malignancy", "In Situ" that are not Colon and Rectum, and also includes records with a Behavior Code of "Malignancy" and are Colon and Rectum.

Correct:

This second example is an even simpler way to do the same thing. The group will include all records with a Behavior Code of "Benign", "Borderline Malignancy", "In Situ" that are not Colon and Rectum, and then include all records for any site that are Behavior Code "Malignant". 

right-img