Chapter Contents

Previous

Next
The GMAP Procedure

Example 5: Creating Maps with Drill-down for the Web


Procedure Features:
CHORO statement options:
DES=
DISCRETE
HTML=
NAME=
BLOCK statement options:
BLOCKSIZE=
DES=
MIDPOINTS=
NAME=
ODS Features:
ODS HTML statement :
BODY=
CONTENTS=
FRAME=
NOGTITLE
PATH=
Other Features:
BY statement
GOPTIONS statement
LEGEND statement
PATTERN statement
TITLE statement
Sample library member: GR19N05

This example shows how to create a 2D choropleth map with simple drill-down functionality for the Web. When this map is displayed in a browser, you can select an area of the map and display additional information about the data.

The example explains how to use the ODS HTML statement and the HTML procedure options to create the drill-down. It shows how to

For more information, see ODS HTML Statement.

The example also illustrates other CHORO and BLOCK statement options.

The program produces one choro map that shows Environmental Protection Agency (EPA) regions and block maps of the states in each region. Each block map shows the number of hazardous waste sites for each state in the selected region. Browser View of Regional Map shows the map of the EPA regions.

Browser View of Regional Map

[IMAGE]

Browser View of Region 5 Block Map shows the block map that appears when you select Region 5 in the map.

Browser View of Region 5 Block Map

[IMAGE]

 Note about code
libname maps 'SAS-MAPS-library';
filename odsout 'path-to-Web-server-space';
 Note about code
ods listing close;
goptions reset=global gunit=pct cback=white
         colors=(black blue green red)
         ftext=swiss htitle=6 htext=3.5;
 Note about code
data sites;
   length stcode $ 2;
   input region stcode $ sites;
   state=stfips(stcode);
   datalines;
1   AK  12
4   AL  7
4   AR  12
2   AZ  10
1   CA  90
1   CO  15
5   CT  15
5   DE  18
4   FL  52
4   GA  15
1   HI  4
3   IA  16
1   ID  8
3   IL  38
3   IN  30
3   KS  10
4   KY  16
4   LA  15
5   MA  30
4   MD  13
5   ME  12
3   MI  72
3   MN  30
3   MO  22
4   MS  1
1   MT  8
4   NC  22
3   ND  0
3   NE  10
5   NH  18
5   NJ  105
2   NM  9
1   NV  1
5   NY  78
3   OH  34
2   OK  10
1   OR  10
5   PA  100
5   RI  12
4   SC  26
3   SD  2
4   TN  14
2   TX  26
1   UT  12
4   VA  25
5   VT  8
1   WA  49
3   WI  40
5   WV  6
1   WY  3
;
 Note about code
data newsites;
   length regiondrill $40;
   set sites;
   if region=1 then
      regiondrill='HREF="hazsite_statebody.html#Region1"';
   if region=2 then
      regiondrill='HREF="hazsite_statebody.html#Region2"';
   if region=3 then
      regiondrill='HREF="hazsite_statebody.html#Region3"';
   if region=4 then
      regiondrill='HREF="hazsite_statebody.html#Region4"';
   if region=5 then
      regiondrill='HREF="hazsite_statebody.html#Region5"';
run;
 Note about code
goptions device=gif transparency;
 Note about code
ods html body='hazsite_mapbody.html'
         contents='hazsite_contents.html'
         frame='hazsite_frame.html'
         nogtitle
         path=odsout;
 Note about code
title1 'Hazardous Waste Sites in EPA Regions (1997)';
footnote1 h=3 j=l 'click on a map region' j=r 'EPAMAP ';
 Note about code
pattern1 value=msolid color=blue;
pattern2 value=msolid color=green;
pattern3 value=msolid color=red;
pattern4 value=msolid color=lime;
pattern5 value=msolid color=cyan;
 Note about code
proc gmap map=maps.us data=newsites;
   id state;
   choro region / discrete
                  html=regiondrill
                  coutline=black
                  nolegend
                  des='EPA Regional Map'
                  name='epamap';
run;
quit;
 Note about code
ods html body='hazsite_statebody.html'
         anchor='Region1'
         gtitle
         path=odsout;
 Note about code
goptions notransparency
         border;
 Note about code
proc sort data=newsites;
   by region;
run;
 Note about code
legend1 shape=bar(3,4)
        label=('Number of Sites'
               position=(top center))
        value=(j=l '0-24' '25-49' '50-74' '75-99' 'over 100')
        frame;
 Note about code
pattern1 value=ms color=gray;
 Note about code
pattern2 value=solid color=lipk;
pattern3 value=solid color=cyan;
pattern4 value=solid color=green;
pattern5 value=solid color=blue;
pattern6 value=solid color=red;
 Note about code
options nobyline;
title1 'Wastes Sites per State in Region #byval(region)';
footnote1 h=3 j=r 'SITEMAP ';
 Note about code
proc gmap map=maps.us data=newsites;
   by region;
   id state;
   block sites / midpoints=(12 37 62 87 112)
                 legend=legend1
                 shape=cylinder
                 blocksize=4
                 coutline=black
                 des='State Maps'
                 name='states01';
run;
quit;
 Note about code
ods html close;
ods listing;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.