A variable is an alias that can refer to some piece of data: a number, text string, column, constant, or matrix. For example, a variable named "Test1" could represent any of the following: a column of test scores, a constant that is the mean of the test scores, or a text string that is the name of the test.
Variables can be utilized in a local macro argument to allow you to enter data as the macro is invoked. They can also be used in a local macro control statement (found in the body of the macro) to enable complex calculations and data manipulations. And, all types of variables have to be declared in a declaration statement.
With global macros, you must provide the specific location, or specific value, of the data that needs to be processed from the command each time a macro is created. The data can not be changed when the global macro is invoked. A local macro can use variables to establish data unknowns that are determined when the macro is invoked. These variables are determined in the macro template, and are considered arguments. For more information on templates, see Writing a Template. For more information on arguments, see Using Arguments.
Local macros also allow you to use temporary variables that are known only to the macro and that are stored in the local worksheet. These temporary variables exist only while the macro is running. They are defined and manipulated using control statements within the body of your macro.
The only way you can utilize results within interactive Minitab or in a global macro is by storing them in the global worksheet as columns, stored constants, or matrices. This can clutter your worksheet, especially if you need a lot of scratch storage.
With local macros, you can store data in variables on the local worksheet and manipulate them as you wish, without affecting your regular worksheet at all. When you exit the local macro, the local variables disappear. These temporary variables are especially useful for performing calculations and using control statements. For more information on control statements, see Control Statement Overview.
In order to use argument or control statement variables, you must first declare the data type of the variable. The data can be text, suffixed, or unknown (considered "free") for all variables. For more information on declaring variables see Declaration Statements.
You should choose a variable name that represents the value that is going to take the place of the variable when the macro is invoked. The following rules apply for naming variables: