Sample 37399: Creating macro variables in Graph Template Language (GTL) using the MVAR statement
This sample illustrates how to use the MVAR statement to define macro variables with the Graph Template Language (GTL). In this sample, the footnote text comes from the value of the macro variable DateTag. DateTag is named in the MVAR (macro variable) statement. The X-axis label is also replaced with the macro variable Xlabel.
When the MVAR statement is used, the template is compiled and the value of the macro variable is substituted when the template is used by the procedure.
This approach lets you modify and compile the template once and then use it repeatedly with different values of the macro variable without having to recompile the template.
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.
This sample illustrates how to use the MVAR statement to define macro variables with the Graph Template Language (GTL). In this sample, the footnote text comes from the value of the macro variable DateTag. DateTag is named in the MVAR (macro variable) statement. The X-axis label is also replaced with the macro variable Xlabel.
proc template;
define statgraph Stat.Glimmix.Graphics.BoxPlot;
dynamic _TITLE _YVAR _SHORTYLABEL;
mvar DateTag Xlabel;
BeginGraph / designwidth=600px designheight=400px;
entrytitle _TITLE;
entryfootnote halign=left textattrs=graphvaluetext datetag;
layout overlay / yaxisopts=(gridDisplay=auto_on shortlabel=_SHORTYLABEL)
xaxisopts=(label=xlabel
discreteopts=(tickvaluefitpolicy=rotatethin));
boxplot y=_YVAR x=LEVEL / labelfar=on datalabel=OUTLABEL
primary=true freq=FREQ;
endlayout;
EndGraph;
end;
run;
%let DateTag = Acme 01Apr2008;
%let xlabel = Gender;
ods html file="glimmix.html" path='.' image_dpi=100;
proc glimmix data=sashelp.class plots=boxplot;
class sex;
model height = sex;
run;
ods html close;
ods listing;
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.
This sample illustrates how to create macro variables in Graph Template Language (GTL) using the MVAR statement.
| Date Modified: | 2009-10-15 10:15:43 |
| Date Created: | 2009-10-08 14:58:53 |
Operating System and Release Information
| SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
| Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
| Microsoft® Windows® for x64 | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
| Microsoft Windows XP Professional | 9.2 TS1M0 | |
| Windows Vista | 9.2 TS1M0 | |
| 64-bit Enabled AIX | 9.2 TS1M0 | |
| 64-bit Enabled HP-UX | 9.2 TS1M0 | |
| 64-bit Enabled Solaris | 9.2 TS1M0 | |
| HP-UX IPF | 9.2 TS1M0 | |
| Linux | 9.2 TS1M0 | |
| Linux for x64 | 9.2 TS1M0 | |
| OpenVMS on HP Integrity | 9.2 TS1M0 | |
| Solaris for x64 | 9.2 TS1M0 | |