/* There is a filename statement in the code below */
/* that must be changed in order for you to */
/* successfully run this code. */
goptions reset=all;
/* This macro creates a gmap 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;
pattern1 v=s c=cxa01010;
pattern2 v=s c=cx108010;
title f=centb h=1.4 "&Name: 1994 Population &Pop";
proc gmap map=maps.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
;
/* This data steps 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 */
/* filename for the GIF file and the necessary goptions */
/* statements to produce the a gif animation and then */
/* invokes the macro that produces the gmaps gif */
/* animation file. You will need to change the filename */
/* statement to direct output to an appropiate file. */
data _null_;
set usa end=done;
file 'temp.sas';
if _n_ = 1
then put "filename animmap 'animmap.gif';" /
"goptions reset=goptions device=gifanim gsfmode=replace gsfname=animmap hsize=8 vsize=6"
"cback=white iteration=0 delay=150 disposal=background;";
else if _n_ = 2
then put "goption gsfmode=append;";
if done then put "goptions gepilog='3B'x;";
put '%onestate(' state ', usa );';
run;
%inc 'temp.sas';