Conditionally executes code based on a test expression.
IF test-expression THEN clause[;ELSEclause];
IF A>B THEN IF C>D THEN X = 5; ELSE X = 10;
In this example, the ELSE clause is associated with IF C > D THEN X = 5 ;
To associate an ELSE with the first THEN, you may write an ELSE or an empty ELSE with the second THEN, as shown in the following examples.
IF A>B; IF C>D THEN X=5; ELSE; ELSE X = 10;
or
IF A>B THEN DO; IF C>D THEN X=5; END; ELSE X = 10;
None.
Description
The IF statement evaluates the test-expression. If the expression is true, the THEN clause is executed; otherwise, the ELSE clause, if present, is executed.
When an IF statement is used as a THEN or ELSE clause of another IF statement, any ELSE is always matched with the nearest unmatched preceding THEN.
test-expressions in IF statements may produce bit(n) values, where n>1. In this case, the test expression will be considered true if any of the bits in the string are 1 and false only when all bits are 0.