Click here to see the SAS code.
Click here to see the example.
This is the first time I've ever seen this done in sas...
I was wanting to see if sas could do maps like this fancy example.
That example was done using 'Flash' technology (I think).
Since not all browsers support flash (such as Apple's
Mobile Safari), and not all users want to load flash-player
software on their pc's, and also the original map was recently
'blasted' in DM Review magazine because it was not a good way
to try to show snowfall amounts on the map - notice that I do
not try to use the map for that :) ... I just use the map to
show the locations of the ski resorts, and provide an easy
interface to get to each of the restorts' webpages.
Therefore, I wanted to do a sas version, using good-old standard
device=png, with ods html charttips/drilldowns for the ski resorts.
First, I took the US county map, and used SAS/Graph 'proc gproject'
to subset out a rectangular-shaped area (based on longitude/latitude)
for the area of interest (extending the area out a comfortable distance
from the borders of Idaho, into neighboring states).
I then used SAS/Graph 'proc gmap' to draw this map, feeding it a data=
data set containing values for all the counties *except* Idaho. Since
the Idaho counties have no data in my response data set, they show up
as 'empty' (aka, clear/see-through) in the map. I used the 'cempty'
otpion to have the borders of the counties show up in these empty areas.
For all the other (surrounding) counties, I used a pattern statement to
color them purple, and specified the same color for the 'coutline'.
Also, I used 'goptions cback=' to color the background that same
color as well. This way, everything except the hole in the map was
solid purple (so they all appear to be background, rather than map
Then, behind the Idaho 'hole' in the map, I annotated an image of
the snow skier (I had to use trial-and-error to get the image in just
the right position, and did a little bit of cropping on the image to
get it just the right size).
If I had used the title statement, the titles would have gone 'above'
the map. To get them beside the map (inside of the map's max/min
x/y coordinates) I used annotate.
I also annotated the ski resorts on the map, and used the annotate
html= variable to provide charttips and drilldowns. I used the zipcode
of the ski resort to lookup the long/lat coordinate in sashelp.zipcode
(this is a rough approximation - if you have actual long/lat of the
ski resorts, you could use that instead).
Back to Samples Index