Sample 49342: Create an animated SVG graph using PROC GCHART
Beginning with SAS® 9.4, you can create animated graphs in scalable vector graphics (SVG) format. New options available in the OPTIONS statement enable you to have a wide range of control over the SVG animation. Note that in order to take advantage of SVG graphics, you must use an SVG-enabled web browser to view the graphics output.
The sample code on the Full Code tab uses PROC GCHART to create an animated graph where the height of bar for each state changes every ten years to show population growth.
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.
Support for animated SVG graphics output is new starting with SAS 9.4. You must be running SAS 9.4 in order to run this sample code.
%macro delcat(catname);
%if %sysfunc(cexist(&catname))
%then %do;
proc greplay nofs igout=&catname;
delete _all_;
run;
quit;
%end;
%mend delcat;
%delcat(work.gseg)
ods _all_ close;
ods listing;
%let name=census;
/* Set up multiple dummy test data sets for use with PROC GCHART */
data census1960;
format population comma12.0;
input st $ 1-2 population;
year=2000;
datalines;
VA 3966949
NC 4556155
SC 2382594
GA 3943116
FL 4951560
;
run;
data census1970;
format population comma12.0;
input st $ 1-2 population;
year=2000;
datalines;
VA 4648494
NC 5082059
SC 2590516
GA 4589575
FL 6789443
;
run;
data census1980;
format population comma12.0;
input st $ 1-2 population;
year=2000;
datalines;
VA 5346818
NC 5881766
SC 3121820
GA 5463105
FL 9746324
;
run;
data census1990;
format population comma12.0;
input st $ 1-2 population;
year=2000;
datalines;
VA 6187358
NC 6628637
SC 3486703
GA 6478216
FL 12937926
;
run;
data census2000;
format population comma12.0;
input st $ 1-2 population;
year=2000;
datalines;
VA 7078515
NC 8049313
SC 4012012
GA 8186453
FL 15982378
;
run;
data census2010;
format population comma12.0;
input st $ 1-2 population;
year=2000;
datalines;
VA 8010245
NC 9345823
SC 4446704
GA 9589080
FL 19251691
;
run;
/* Set the size of the SVG graph */
options svgheight='400px' svgwidth='600px';
/* Set the DEVICE= option to SVG */
goptions reset=all device=svg ftext="Albany AMT" htext=12pt border;
/* Set the system options to control the SVG animation */
options printerpath=svg animate=start animduration=3 svgfadein=1 animloop=1
animoverlay nodate nonumber;
/* Use PROC GCHART with the ODS HTML5 statement */
/* to create the final animated graph. */
ods _all_ close;
ods html5 file='svg_census.html' options(svg_mode='inline');
title h=18pt "Population Growth 1960-2010";
title2 "Year 1960 U.S. Census Population";
proc gchart data=census1960;
vbar st / sumvar=population sum raxis=axis1 patternid=midpoint width=15;
axis1 order=(0 to 21000000 by 3000000) label=('Population');
axis2 label=('State');
run;
quit;
title2 "Year 1970 U.S. Census Population";
proc gchart data=census1970;
vbar st / sumvar=population sum raxis=axis1 patternid=midpoint width=15;
axis1 order=(0 to 21000000 by 3000000) label=('Population');
axis2 label=('State');
run;
quit;
title2 "Year 1980 U.S. Census Population";
proc gchart data=census1980;
vbar st / sumvar=population sum raxis=axis1 maxis=axis2 patternid=midpoint width=15;
axis1 order=(0 to 21000000 by 3000000) label=('Population');
axis2 label=('State');
run;
quit;
title2 "Year 1990 U.S. Census Population";
proc gchart data=census1990;
vbar st / sumvar=population sum raxis=axis1 maxis=axis2 patternid=midpoint width=15;
axis1 order=(0 to 21000000 by 3000000) label=('Population');
axis2 label=('State');
run;
quit;
title2 "Year 2000 U.S. Census Population";
proc gchart data=census2000;
vbar st / sumvar=population sum raxis=axis1 maxis=axis2 patternid=midpoint width=15;
axis1 order=(0 to 21000000 by 3000000) label=('Population');
axis2 label=('State');
run;
quit;
title2 "Year 2010 U.S. Census Population";
proc gchart data=census2010;
vbar st / sumvar=population sum raxis=axis1 maxis=axis2 patternid=midpoint width=15;
axis1 order=(0 to 21000000 by 3000000) label=('Population');
axis2 label=('State');
run;
quit;
options animate=stop;
ods _all_ 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 an animated SVG graph using the GCHART procedure.
Date Modified: | 2013-07-02 08:58:09 |
Date Created: | 2013-03-04 14:14:50 |
Operating System and Release Information
SAS System | N/A | Greenplum on Linux x64 | 9.4 TS1M0 | |
z/OS | 9.4 TS1M0 | |
Z64 | 9.4 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.4 TS1M0 | |
Microsoft Windows XP 64-bit Edition | 9.4 TS1M0 | |
Microsoft® Windows® for x64 | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 for x64 | 9.4 TS1M0 | |
Microsoft Windows Server 2008 | 9.4 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.4 TS1M0 | |
Microsoft Windows XP Professional | 9.4 TS1M0 | |
Windows 7 Enterprise 32 bit | 9.4 TS1M0 | |
Windows 7 Enterprise x64 | 9.4 TS1M0 | |
Windows 7 Home Premium 32 bit | 9.4 TS1M0 | |
Windows 7 Home Premium x64 | 9.4 TS1M0 | |
Windows 7 Professional 32 bit | 9.4 TS1M0 | |
Windows 7 Professional x64 | 9.4 TS1M0 | |
Windows 7 Ultimate 32 bit | 9.4 TS1M0 | |
Windows 7 Ultimate x64 | 9.4 TS1M0 | |
Windows Vista | 9.4 TS1M0 | |
Windows Vista for x64 | 9.4 TS1M0 | |
64-bit Enabled AIX | 9.4 TS1M0 | |
64-bit Enabled HP-UX | 9.4 TS1M0 | |
64-bit Enabled Solaris | 9.4 TS1M0 | |
HP-UX IPF | 9.4 TS1M0 | |
Linux for x64 | 9.4 TS1M0 | |
Linux on Itanium | 9.4 TS1M0 | |
Solaris for x64 | 9.4 TS1M0 | |