Conditional Expression Constructors

Use the following as conditional expression constructors.
  • $if
  • $and
  • $or (inclusive)
  • $xor (exclusive, this construction is not available on a button and must be typed in)
  • $not
  • (
  • )
  • ,
A conditional expression is of the form
$if (Expression, trueValue, falseValue)
If the expression reduces to a value of false (zero), the result is falseValue. If the expression reduces to a value of true (nonzero), the result is trueValue. For example, if A and B are variables in your dataset, and you create a New variable such that
New = $if((!A! < 123.0) $and (!B! < 123.0), 0.0, 123.0)
then the value of New will be 0 in any data rows in which both A and B are less than 123, and New will be 123 when A or B or both reach 123.
NOTE:
A conditional expression of the form $if(!x!=22.1) does not tolerate inexactness in numeric comparisons. $if(!x!=22.1) will fail if x is 22.099 or 22.101. For a “close to equal” test, use the $withinPct transform, or construct an explicit test such as $if((22.09<!x!)$and(!x!<22.11)).
Conditional expressions can be nested. For example:
New = $if(!A! < 10.0), 1.0, $if(!A! < 100.0, 2.0, $if(!A! < 1000.0, 3.0, 0.0)))
which is expressed verbally as “if A is less than 10, the result is 1; otherwise, if A is less than 100, the result is 2; otherwise, if A is less than 1000, the result is 3; otherwise, the result is 0.” See also the $findLE transform, which functions as a multiply nested if-less-than-or-equal.
See also the transforms $isBadStatus, $isBreak, and $isValid, described in“Transform Reference”.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.