Composing Macros


A macro definition is composed of a macro name, arguments required to execute the macro, and a macro body or expansion. For example, the macro below performs series smoothing using a moving average.




In this example, the macro name is SMOOTH, the argument list contains only argument, S, and the macro expansion is: MOVAVG(S, CEIL(0.1*LENGTH(S))). This macro smoothes a data series by performing a moving average where the size of the moving average window is one tenth of the series' length (rounded to an integer value). To use the SMOOTH macro, type the command:




It is important to note that macros are simply text substitutions. Typing the macro SMOOTH(W1) on the command line is equivalent to typing:




Macros can have up to ten arguments. There are no restrictions on the data types or the names used as arguments. Optional arguments are not allowed. Macro names may be up to 15 characters long. Macro definitions are limited to one line, that is, the total number of characters used in the macro name, argument list, and macro expansion (including spaces) must be less than 256 characters.