Nested logic

 

You can create logic statements that have more than one expression. Use braces { } to indicate which expressions should be evaluated together and the order in which the expressions should be considered. Expressions become ‘nested’ within statements, so this is called ‘nested logic.’

 

One set of braces can appear within another and an unlimited number of braces may be used in a statement. There must be an equal number of left and right braces in a statement; a statement missing a brace won't pass the syntax check when you run tables.

 

Expressions in braces are evaluated first, with all evaluation occurring left to right, within braces and across expressions.

 

Example 1 (Variable data):

 

{GENDER (1) AND INCOME (3)} OR Q1 (44)

 

Example 2 (ASCII data):

 

{1/5 (1) AND 1/66 (3)} OR 1/32:2 (44)

 

Using NOT (?) with nested logic permits an additional level of control. When you precede an expression with NOT, it changes the statement to test for a condition not to exist.

 

For example, if you put braces around the first statement and precede it with NOT:

 

NOT {MALE AND {OVER_44 OR CHICAGO}}

 

it would look for respondents who are NOT males over 44 or males living in Chicago.

Related topics:

 Logic