Sample 37261: Using SAS/GRAPH® to create scalable vector graphics (SVG) output
Starting with SAS® 9.2, you can use SAS/GRAPH to create scalable vector graphics (SVG) output. The Full Code tab contains sample SAS code that demonstrates the following two methods for creating SVG output:
- Using the SVG device driver with the ODS HTML statement.
- Using the PRINTERPATH=SVGT system option with the ODS PRINTER statement.
Note that in order to view SVG output, you need to use an SVG-enabled web browser. To enable SVG viewing with Microsoft Internet Explorer, the recommended plug-in is Adobe's SVG viewer. Other popular web browsers, such as Firefox 1.5 or later, support SVG by default.
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 SAS code demonstrates two methods for creating SVG output.
/* This sample program uses the SVG SAS/GRAPH */
/* device driver with the ODS HTML statement. */
/* This sample code demonstrates how to create */
/* scalable vector graphics output that */
/* provides pop-up tool tips along with drill */
/* down capability. */
filename odsout 'c:\temp';
%let textcolor=gray66;
proc format;
value measfmt
1='Satisfaction with\SAS software'
2='Satisfaction with\SAS relationship'
3='Likely to\recommend renewal';
run;
data mydat;
format Satisfaction percent7.0;
format Measure measfmt.;
input Measure Training $ 3-19 Satisfaction;
cards;
1 Attended Training .93
1 No Training .86
2 Attended Training .85
2 No Training .76
3 Attended Training .92
3 No Training .84
;
run;
data my_data;
set mydat;
length myhtml $ 1024;
myhtml='title='|| quote( trim(left(put(measure,measfmt.))) || '0d'x
|| 'Statisfaction: ' || trim(left(put(satisfaction,percent7.0)))||' ')
|| 'href="http://sww.sas.com/"';
run;
goptions reset=goptions device=svg;
ods listing close;
ods html path=odsout body="svgsample1.htm" (title="SAS Customer Satisfaction & Training");
goptions noborder;
goptions gunit=pct htext=3.1 ctext=&textcolor ftext="Thorndale AMT/bold";
goptions cback=white;
axis1 c=graycc label=none value=none;
axis2 c=graycc label=none value=(c=&textcolor) order=(.60 to .95 by .05) minor=none offset=(0,0);
axis3 c=graycc label=none value=(c=&textcolor height=3) split='\' offset=(7,5);
legend1 position=(middle right) mode=share shape=bar(.12in,.12in) across=1 label=none offset=(1,28);
pattern1 value=solid color=cx1b3f8b;
pattern2 value=solid color=cxcd0000;
title1 h=10 " ";
title2 j=left c=gray55 f="Thorndale AMT/bold" h=6 " Training Drives Satisfaction & Loyalty";
title3 j=left ls=1.1 " Creating Opportunity for New Sales";
title4 h=4 " ";
title5 a=-90 h=3 " ";
footnote1 h=3 " ";
footnote2 j=left " ** Training customers happier in all 31 measures";
footnote3 h=2 " ";
proc gchart data=my_data;
vbar3d Training / discrete
type=sum sumvar=Satisfaction
outside=sum
group=Measure
cframe=white
space=0
width=10
gspace=15
subgroup=Training
maxis=axis1
raxis=axis2
gaxis=axis3
coutline=same
legend=legend1
noframe
html=myhtml
des="";
run;
quit;
axis4 c=graycc label=none value=(c=&textcolor) order=(0 to 1.00 by .20) minor=none offset=(0,0);
legend2 position=(middle right) mode=share shape=bar(.12in,.12in) across=1 label=none offset=(1,31);
proc gchart data=my_data;
vbar3d Training / discrete
type=sum sumvar=Satisfaction
outside=sum
group=Measure
cframe=white
space=0
width=10
gspace=15
subgroup=Training
maxis=axis1
raxis=axis4
gaxis=axis3
coutline=same
legend=legend2
noframe
des="";
run;
quit;
proc gchart data=my_data;
vbar Training / discrete
type=sum sumvar=Satisfaction
outside=sum
group=Measure
cframe=white
space=0
width=10
gspace=15
subgroup=Training
maxis=axis1
raxis=axis4
gaxis=axis3
coutline=graycc
legend=legend2
noframe
des="";
run;
quit;
ods html close;
ods listing;
/* This sample program uses the PRINTERPATH=SVGT */
/* system option together with the ODS PRINTER */
/* statement. The SVGT printer is used to create */
/* output with no background, producing a */
/* transparent effect. Each page in the document */
/* is overlaid. This allows you to see through */
/* to all pages in the document. This is an */
/* example of overlaying a bar chart with a */
/* transparent background onto a map with the */
/* SVGT printer. This allows the map area behind */
/* the bar chart to be visible. */
data boxanno;
length function color style $20 text $16;
retain xsys ysys '2' hsys '3' when 'a';
set maps.uscity(keep=x y city state);
where city='Raleigh' and state=stfips('NC');
color='blue'; size=4; text='V'; position='5'; style='marker'; output;
myx=x;
myy=y;
function='move';
x=myx; y=myy; output;
function='draw';
x=myx-.432; y=myy+.0417; color='gray'; line=1; size=.2; style='solid'; output;
function='move';
x=myx; y=myy; output;
function='draw';
x=myx-.432; y=myy+.178; output;
function='move';
x=myx; y=myy; output;
function='draw';
x=myx-.251; y=myy+.178; output;
function='move';
x=myx; y=myy; output;
function='draw';
x=myx-.251; y=myy+.0417; output;
run;
%let name=annomap;
goptions reset=all border gunit=pct htitle=5 htext=3
ftext="arial/bo";
options printerpath=svgt nodate nonumber;
ods listing close;
ods printer file='c:\temp\annomap.svg' ;
pattern1 v=s c=cornsilk;
title1 c=red "SAS/Graph gmap and overlayed gchart with printerpath=svgt";
proc gmap data=maps.us map=maps.us ;
id state;
choro state / levels=1 nolegend coutline=blue anno=boxanno
des="" name="&name";
run;
quit;
goptions hsize=2.07 vsize=1.57 horigin=2.1
vorigin=3.12 autosize=on device=svgt;
/* You must use the default ODS style for transparency to work */
goptions gunit=pct htext=12 ftext="Albany AMT" ;
title 'Transparent SVG';
pattern1 v=s c=red;
axis1 label=none value=none major=none minor=none style=0;
axis2 color=blue label=none offset=(7,7) value=(color=blue);
proc gchart data=sashelp.class;
vbar3d age / discrete descending raxis=axis1 maxis=axis2 width=9 space=5
frame autoref coutline=blue woutline=1
des="" name="&name.b";
run;
quit;
ods printer 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.
Using SAS/GRAPH® to create scalable vector graphics (SVG) output.
Date Modified: | 2009-09-25 14:39:37 |
Date Created: | 2009-09-25 11:21:36 |
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 Server 2008 | 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 | |