IF, ELSEIF, ELSE, ENDIF
    

IF     logical expression

        (a block of Minitab and macro commands)

ELSEIF logical expression

        (a block of Minitab commands and macro statements)

ELSE

        (a block of Minitab commands and macro statements)

ENDIF

Allows you to execute different blocks of code depending on a logical condition. A logical expression is any expression from the LET command. The comparison and Boolean operators listed below are the features of LET that are most often used in IF.

=

or

EQ

equal to

&

or

AND

~=

or

NE

not equal to

|

or

OR

<

or

LT

less than

~

or

NOT

>

or

GT

greater than

 

 

 

<=

or

LE

less than or equal to

 

 

 

>=

or

GE

greater than or equal to

 

 

 

In most cases the logical expression evaluates to a single number. If the number is 0 (false), the block of statements is skipped; if it is not 0 (true), the block is executed. If the logical expression evaluates to a column, then if all entries in the column are 0, the expression is considered false, otherwise it is considered true.

You can use multiple ELSEIF statements within the IF-ENDIF block.

Here is a simple example, using a global macro:

GMACRO
SMALL
#
# Takes the data in C1-C3. Finds the column with the smallest mean
# and prints it out. If, because of ties, there is no single column
# with the smallest mean, a message is printed.
#
LET K1 = MEAN(C1)
LET K2 = MEAN(C2)
LET K3 = MEAN(C3)
IF K1 < K2 AND K1 < K3
  PRINT C1
ELSEIF K2 < K1 AND K2 < K3
  PRINT C2
ELSEIF K3 < K1 AND K3 < K2
  PRINT C3
ELSE
  NOTE Note: There are ties.
ENDIF
ENDMACRO