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.
This example includes the results when the dynamic variable Money = 'Returns'.
proc template;
define statgraph drawtext;
begingraph;
dynamic money _byval_;
entryfootnote ' ' / textattrs=(size=30);
if(colname(money)='Sales')
entrytitle 'Shoe Sales in ' _byval_ ;
layout overlay / xaxisopts=(display=(line ticks));
barchart x=product y=sales / dataskin=sheen group=product fillattrs=GraphData3;
referenceline y=eval(mean(sales)) / lineattrs=(color=green)
curvelabel=eval(putn(mean(sales),'dollar12.2'))
curvelabelattrs=(color=green);
drawtext 'Sandal' / x='Sandal' y=-5 anchor=top justify=center
xspace=datavalue yspace=datapercent width=15;
drawtext 'Boot' / x='Boot' y=-5 anchor=top justify=center xspace=datavalue
yspace=datapercent width=15;
drawtext 'Slipper' / x='Slipper' y=-5 anchor=top justify=center
xspace=datavalue yspace=datapercent width=15;
drawtext 'Sport Shoe' / x='Sport Shoe' y=-5 anchor=top justify=center
xspace=datavalue yspace=datapercent width=15;
drawtext "Men's Dress" / x="Men's Dress" y=-5 anchor=top justify=center
xspace=datavalue yspace=datapercent width=15;
drawtext "Women's Casual" / x="Women's Casual" y=-5 anchor=top
justify=center xspace=datavalue
yspace=datapercent width=15;
drawtext "Women's Dress" / x="Women's Dress" y=-5 anchor=top
justify=center xspace=datavalue
yspace=datapercent width=15;
drawtext "Men's Casual" / x="Men's Casual" y=-5 anchor=top justify=center
xspace=datavalue yspace=datapercent width=15;
drawtext 'Type of Shoe' / x=50 y=2 justify=center xspace=graphpercent
yspace=graphpercent width=30;
endlayout;
endif;
if (colname(money)='Returns')
entrytitle 'Shoe Returns in ' _byval_ ;
layout overlay / ;
barchart x=product y=returns / dataskin=sheen group=prodfill
orient=horizontal fillattrs=GraphData3;
referenceline x=eval(mean(returns)) / lineattrs=(color=red)
curvelabel=eval(putn(mean(returns),'dollar12.2'))
curvelabelattrs=(color=red);
endlayout;
endif;
endgraph;
end;
run;
proc sort data=sashelp.shoes out=shoes;
by region;
run;
proc sgrender data=shoes template=drawtext;
where region in('United States' 'Canada');
by region;
dynamic money='Returns';
run;
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.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGRENDER |
Date Modified: | 2013-04-30 16:10:51 |
Date Created: | 2013-04-19 14:45:55 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | Aster Data nCluster on Linux x64 | 9.3 TS1M0 | |
DB2 Universal Database on AIX | 9.3 TS1M0 | |||
DB2 Universal Database on Linux x64 | 9.3 TS1M0 | |||
Greenplum on Linux x64 | 9.3 TS1M0 | |||
Netezza TwinFin 32bit blade | 9.3 TS1M0 | |||
Netezza TwinFin 32-bit SMP Hosts | 9.3 TS1M0 | |||
Netezza TwinFin 64-bit S-Blades | 9.3 TS1M0 | |||
Netezza TwinFin 64-bit SMP Hosts | 9.3 TS1M0 | |||
Teradata on Linux | 9.3 TS1M0 | |||
z/OS | 9.3 TS1M0 | |||
Z64 | 9.3 TS1M0 | |||
Microsoft® Windows® for x64 | 9.3 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M0 | |||
Microsoft Windows Server 2003 for x64 | 9.3 TS1M0 | |||
Microsoft Windows Server 2008 | 9.3 TS1M0 | |||
Microsoft Windows Server 2008 for x64 | 9.3 TS1M0 | |||
Microsoft Windows XP Professional | 9.3 TS1M0 | |||
Windows 7 Enterprise 32 bit | 9.3 TS1M0 | |||
Windows 7 Enterprise x64 | 9.3 TS1M0 | |||
Windows 7 Home Premium 32 bit | 9.3 TS1M0 | |||
Windows 7 Home Premium x64 | 9.3 TS1M0 | |||
Windows 7 Professional 32 bit | 9.3 TS1M0 | |||
Windows 7 Professional x64 | 9.3 TS1M0 | |||
Windows 7 Ultimate 32 bit | 9.3 TS1M0 | |||
Windows 7 Ultimate x64 | 9.3 TS1M0 | |||
Windows Vista | 9.3 TS1M0 | |||
Windows Vista for x64 | 9.3 TS1M0 | |||
64-bit Enabled AIX | 9.3 TS1M0 | |||
64-bit Enabled HP-UX | 9.3 TS1M0 | |||
64-bit Enabled Solaris | 9.3 TS1M0 | |||
HP-UX IPF | 9.3 TS1M0 | |||
Linux | 9.3 TS1M0 | |||
Linux for x64 | 9.3 TS1M0 | |||
Solaris for x64 | 9.3 TS1M0 |