Do you have fun being a computer geek, and programmatically creating holiday images? If so, then this blog's for you!
In this example, I demonstrate how to take simple x/y coordinates, and create map polygons shaped like holiday images, that can be plotted using SAS/Graph's Proc GMap. Once you learn the basic technique, you can easily re-use this code to create your own images. :)
First, we need some x/y coordinates. I did a few Google searches and found several nice Halloween examples at math-aids.com. I chose the bat, and copy-n-pasted the x/y coordinates into the datalines section of my SAS job. Below is some partial code (you can click here to see the full code) that reads the x/y coordinates into a dataset that can be plotted as a geographical map.
data bat_data; id='bat'; input x y; datalines; 7 6 8 5 9.5 4 11 3.5 13 3 (several data lines not shown) 0 2.5 1 3 3 4 5 5 ; run;
You can plot the x/y coordinates on a scatter plot, to see what they look like:
But what we really want is a polygon, filled with a color. You can plot the data as a polygon using Proc GMap, and the polygon named 'bat' will be treated just like a state in the US map:
title "Bat Polygon"; proc gmap data=bat_data map=bat_data; id id; choro id / nolegend coutline=red; run;
That's pretty good ... but the bat on math-aids.com had eyes. We can create the eyes by making a hole in the map polygon. All you need to do is insert a 'missing' value in the coordinates, and then all the coordinates after that are used to create a hole in the polygon. The following data adds two holes to the bat polygon to create two triangle-shaped eyes:
data bat_data; id='bat'; input x y; datalines; 7 6 8 5 9.5 4 11 3.5 13 3 (several data lines not shown) 0 2.5 1 3 3 4 5 5 . . -3 4 -2.5 4.5 -2.5 3.5 . . -2 3.5 -1 4 -1 3.5 ; run;
My full code also creates a cat and a witch. If you're teaching someone how to use SAS, you might want to give them the data, and have them try to figure out what the x/y points represent. You could let them try to analyze the data using any proc they want, and then later give them the hint that they might want to try Proc GMap.