The sample code below uses the GIFANIM device driver to create an animated map of the US. You must view the resulting GIF file in a web browser in order to see the animation.
The graphics output on the Results tab was produced using SAS® 9.2. Submitting the sample code with other releases of SAS might produce different results.
/* This macro creates one graph each time it is invoked */
%macro onestate( state, ds );
data one;
set &ds;
call symput( 'Pop', left( put( Pop94, comma11. ) ) );
call symput( 'Name', trim( fipnamel( state ) ) );
if state = &State
then do;
ThisOne = 'A';
output;
stop;
end;
else do;
ThisOne = 'B';
output;
end;
run;
data work.us;
set maps.us;
where fipstate(state) NE "PR";
run;
title1 "&Name: 1994 Population &Pop";
proc gmap map=work.us data=one all;
id state;
choro ThisOne / nolegend coutline=black;
run;
quit;
%mend;
/* The following information is taken from the USAAS map */
/* data in the MAPS library that is included with SAS/GIS. */
data usaa;
input State POP94 comma11.;
datalines;
1 4,221,932
2 610,350
4 4,000,398
5 2,441,646
6 31,546,602
8 3,630,585
9 3,275,195
10 707,864
11 571,592
12 13,849,741
13 7,020,384
15 1,186,692
16 1,120,679
17 11,760,900
18 5,752,928
19 2,823,048
20 2,543,745
21 3,814,122
22 4,313,195
23 1,241,451
24 5,008,060
25 6,012,972
26 9,521,288
27 4,550,733
28 2,659,929
29 5,262,100
30 848,637
31 1,613,762
32 1,431,731
33 1,129,184
34 7,915,280
35 1,640,014
36 18,248,700
37 7,019,142
38 634,353
39 11,149,084
40 3,251,236
41 3,076,269
42 12,088,344
44 999,362
45 3,678,846
46 719,616
47 5,151,582
48 18,276,706
49 1,892,307
50 579,094
51 6,563,063
53 5,345,474
54 1,826,545
55 5,072,574
56 473,863
;
run;
/* This DATA step sorts the data to show */
/* the highest population first. */
proc sort data=usaa out=usa;
by descending pop94;
run;
/* This DATA step creates a SAS program that sets up the */
/* file name for the GIF file and the graphics options */
/* that are needed to produce the GIF animation. The */
/* code then invokes the macro that produces the GIF */
/* animation file. */
/* This sample code writes its output to C:\TEMP (when */
/* the code is run on the Windows operating system). */
/* Modify the FILE and %INC statements below if you want */
/* to write the output to a location other than C:\TEMP */
/* or if you are running on an operating system other */
/* than Windows. */
data _null_;
set usa end=done;
file 'c:\temp\temp.sas';
if _n_ = 1
then put "filename animmap 'c:\temp\animmap.gif';" /
"goptions reset=goptions device=gifanim gsfmode=replace gsfname=animmap xpixels=600 ypixels=400"
"cback=white iteration=0 delay=150 disposal=background border htitle=13pt;";
else if _n_ = 2
then put "goptions gsfmode=append;";
if done then put "goptions gepilog='3B'x;";
put '%onestate(' state ', usa );';
run;
ods _all_ close;
ods listing;
%inc 'c:\temp\temp.sas';
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.