This content describes Snap 11. For Snap 10, the equivalent page will be in Snap 10 help

Next Topic

Book Contents

Book Index

Logical to Numerical Conversions

The NUM function converts logical values into numerical values. This is useful in circumstances where, for example, it is required to add one number to another. The general use is:

NUM (<logical value>)

If <logical value> is TRUE then NUM gives 1 as its result.

If <logical value> is FALSE then NUM gives 0 as its result.

If <logical value> is missing (e.g. an error has occurred) then NUM gives Error as its result.

There are a wide variety of uses for such a facility; as an example if it was required to weight a table by factors according to whether the respondent were male (SEX=1) or female (SEX=2), that could be done without the need to set up a weight matrix by specifying the weight as:

NUM (SEX=1) * 1.3 + NUM (SEX=2) * 1.5

The above would weight all cases for males by a factor of 1.3 and all cases for females by 1.5. Cases where SEX had a missing value would not be included in the table at all.

See Also

Lists and ranges

Numeric Expressions

Logical Expressions

Date and time expressions

Literal expressions

Mask Expressions

Axis Expressions