Sample 49345: Create an animated SVG graph using PROC GMAP
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 uses PROC GMAP with the BLOCK statement to create an animated graph showing the number of medals awarded per region.
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;
/* Create a test data set for use with PROC GMAP */
data work.mydata;
input statename $ 1-20 st $ 22-23 dataregion $25-34 region medals;
label st='State';
label medals='Number of Medals';
datalines;
ALABAMA AL Southeast 2 2
ALASKA AK Northwest 4 .
ARIZONA AZ Southwest 5 7.99
ARKANSAS AR Southeast 2 .
CALIFORNIA CA Southwest 5 3
COLORADO CO Southwest 5 .
CONNECTICUT CT Northeast 1 -0
DELAWARE DE Northeast 1 .
DISTRICT OF COLUMBIA DC Northeast 1 .
FLORIDA FL Southeast 2 5.75
GEORGIA GA Southeast 2 1
HAWAII HI Southwest 5 .
IDAHO ID Northwest 4 .
ILLINOIS IL Midwest 3 .
INDIANA IN Northeast 1 1
IOWA IA Midwest 3 .
KANSAS KS Midwest 3 -10
KENTUCKY KY Northeast 1 .
LOUISIANA LA Southeast 2 .
MAINE ME Northeast 1 -1
MARYLAND MD Northeast 1 1
MASSACHUSETTS MA Northeast 1 .
MICHIGAN MI Northeast 1 2
MINNESOTA MN Midwest 3 .150
MISSISSIPPI MS Southeast 2 .
MISSOURI MO Midwest 3 .
MONTANA MT Northwest 4 0
NEBRASKA NE Midwest 3 .
NEVADA NV Southwest 5 3
NEW HAMPSHIRE NH Northeast 1 .
NEW JERSEY NJ Northeast 1 -4.25
NEW MEXICO NM Southwest 5 .
NEW YORK NY Northeast 1 2
NORTH CAROLINA NC Southeast 2 6
NORTH DAKOTA ND Midwest 3 .
OHIO OH Northeast 1 1
OKLAHOMA OK Midwest 3 .
OREGON OR Northwest 4 -9
PENNSYLVANIA PA Northeast 1 2
RHODE ISLAND RI Northeast 1 .
SOUTH CAROLINA SC Southeast 2 1
SOUTH DAKOTA SD Midwest 3 .
TENNESSEE TN Northeast 1 .
TEXAS TX Midwest 3 -3
UTAH UT Southwest 5 .
VERMONT VT Northeast 1 -7.99
VIRGINIA VA Northeast 1 1
WASHINGTON WA Northwest 4 .
WEST VIRGINIA WV Northeast 1 10
WISCONSIN WI Midwest 3 0
WYOMING WY Northwest 4 .
;
run;
data work.my_us;
length st $2.;
set maps.us;
st=fipstate(state);
label st='State';
run;
proc sort data=mydata;
by region;
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 svgautoplay animloop=yes animduration=3
svgfadein=2 svgfadeout=2 nodate nonumber;
/* Use PROC GMAP with the ODS HTML5 statement */
/* to create the final animated graph. */
ods _all_ close;
ods html5 file='svg_gmap.html' options(svg_mode='inline');
title 'Number of Medals Awarded per Region';
proc gmap map=work.my_us data=work.mydata all uniform;
id st;
by region;
area dataregion;
block medals / discrete name='blockmap';
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 GMAP procedure.
Date Modified: | 2013-07-02 09:20:01 |
Date Created: | 2013-03-04 14:38:40 |
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 | |