Declaring Dynamics and Macro Variables

Within the scope of a template definition, GTL supports the DYNAMIC statement for declaring dynamic variables, and the MVAR and NMVAR statements for declaring macro variables. These statements must appear after the DEFINE statement and before the BEGINGRAPH block. The following syntax shows the overall template structure:
PROC TEMPLATE;
DEFINE STATGRAPH template-name;
DYNAMIC variable-1 <"text-1"> <...variable-n<"text-n">>;
MVAR variable-1 <"text-1"> <...variable-n<"text-n">>;
NMVAR variable-1 <"text-1"> <...variable-n<"text-n">>;
BEGINGRAPH;
GTL statements;
ENDGRAPH;
END;
RUN;
The difference between the MVAR and NMVAR declaration of macro variables is that NMVAR always converts the supplied value to a numeric token (like the SYMGETN function of the DATA step). Macro variables that are defined by MVAR resolve to strings (like the SYMGET function of the DATA step).
Each of the DYNAMIC, MVAR, and NMVAR statements can define multiple variables and an optional text string that denotes its purpose or usage:
dynamic YVAR "required" YLABEL "optional";
mvar LOCATE "can be INSIDE or OUTSIDE" SYSDATE;
nmvar TRANS "transparency factor";
Note: To make the template code more readable, it is helpful to adopt a naming convention for these variables to distinguish them from actual option values or column names. Common conventions include capitalization or adding leading or trailing underscores to their names. The examples in this document use capitalization to indicate a dynamic or macro variable.