SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 49700: Define a dynamic template definition with the Graph Template Language (GTL)

DetailsCodeResultsAboutRate It
Using dynamic variables gives you the flexibility to change variable assignments within the template definition from PROC SGRENDER without recompiling your template definition. You can either define your own dynamic variables with the Graph Template Language (GTL) or use any of the special dynamic variables. For more information about special variables, see the "Special Dynamic Variables" section of the SAS® 9.3 ODS Graphics Procedures Guide, Third Edition (support.sas.com/documentation/cdl/en/grstatproc/65235/PDF/default/grstatproc.pdf).

The special variables are defined in the DYNAMIC statement after the BEGINGRAPH statement within your template definition. The values are assigned later in the DYNAMIC statement in PROC SGRENDER. Special dynamic variables are also defined in the DYNAMIC statement in your template definition, but you do not need to assign a value to the variable in the DYNAMIC statement inside of PROC SGRENDER.

In the sample code on the Full Code tab, the dynamic variable Money is defined in the DYNAMIC statement in the template. Using IF logic, you can define a template definition that creates a vertical bar chart if the value of Money is Sales, and a horizontal bar chart if the value of Money is Returns.

Expressions are used to set option values that are constants, columns, or part of the text for some statements. The EVAL expression is specific to GTL and is used in combination with Base SAS® and GTL functions. In the example, the EVAL expression defines the X/Y location of the REFERENCELINE and the value that is to be displayed for the curve label. Within the EVAL expression, the MEANS function is used to return the mean value of Returns or Sales. The result is formatted using the dollar10.2 format.


These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.