All variables used in a local macro must be declared. Declaring a variable tells the local macro what type of variable to expect from the user, or the macro, while invoking.
For example, suppose the template is
TRIM X Xbar
TRIM is the name of the macro and X and Xbar are variables that will be passed into the macro. The macro would need declaration statements that define whether X and Xbar are constants, columns, matrices, or "free" variables (defined below). Let's say X is a column in the global worksheet and Xbar is a constant in the global worksheet. The user would invoke the macro by typing, say, %TRIM C5 K1. The first few lines of the local macro file would then be
MACRO
TRIM X Xbar
MCOLUMN X
MCONSTANT Xbar
Note If you see the error "Missing END for READ, SET, or INSERT," it may be because you have named a local variable with the same name as a Minitab command, and entered it after READ, SET, or INSERT. For example:
SET col1
min:max/1
END
where min and max are local variable names. Minitab interprets the second line as a command because MIN and MAX are also Minitab commands. It displays the error message because it thinks you are trying to execute a command without first having entered the required END statement. You must avoid using Minitab commands for variable names if you need to use them in this way.
There are four special-purpose variables, which are each declared differently:
Subcommand: An implicit constant that has a value of either 1 (if the subcommand was invoked) or 0 (if the subcommand was not invoked)
Text: Declared with MCONSTANT as a text constant that contains a text string
Suffixed: Declared with MCOLUMN or MCONSTAN as a range of columns or constants
Free: Declared with MFREE as a column, constant, or matrix whose type is undetermined until the macro is invoked