Tracking Ebola: Layering Customized SAS Maps

There are many ways to use SAS in health and life sciences, and one of my favorites is using it to track the spread of diseases. This post demonstrates how to layer several customized maps to track the recent Ebola outbreak in Africa.

For those of you who are impatient and want to cut to the chase, here's my final map. It's a SAS version of a map that appeared in a recent article on the website. Click on it to see the interactive version with html hover-text.


And here are the technical details of how I created this map.

I used the new mapsgfk maps that we started shipping in SAS 9.4 for this example. I started with the mapsgfk.Africa continent map, and used Proc Gproject to chop out just the rectangular area, based on latitude/longitude values, that was in the original article. (This is a technique I learned from Mike Zdeb's wonderful book Maps Made Easy Using SAS.)

proc gproject out=my_map latlong eastlong degrees 
 latmax=14.0 latmin=0
 longmin=-20 longmax=-3.2;
id id;

I created some map data so that the affected countries mapped to the light yellow color, and left the other countries gray (using 'cdefault=grayE1').

That was the easy/straightforward part. Next I needed to add the individual country maps for Guinea and Liberia. I was able to use mapsgfk.Guinea as-is, but mapsgfk.Liberia's areas were one level more granular than I needed (such as US counties, instead of states). Therefore I had to use Proc Gremove to group those lower-level areas into the desired areas. Once I had created these two maps, I combined them with the previous map, layering them such that these two new maps come last in the dataset, so they will show up "on top."

We've now got a map with the countries and areas together, but it's difficult to determine exactly which country the smaller areas are a part of. Therefore I took the country borders, and created an annotate dataset to draw a dark outline around each country using the poly/polycont annotate commands. This is an improvement over the original map, by the way!

And to finish it off, I annotated country and city names at specific latitude/longitude coordinates, and annotated a blue rectangle behind the map to represent the ocean. I annotated the "Capitals" marker to the legend, and added the date to the bottom/right. I added HTML hover-text to all the countries and areas within the countries, using the Gmap html= option, so you can mouse over them and see what the names are (which is another enhancement over the original map). Scroll back to the top of the blog to see the finished map.

As you can see, you can do a lot of customizations in SAS maps, and you can layer maps (and also annotations) to create some really detailed maps to help visualize and analyze your data. Now that you know what's possible, what data do you think it would be interesting to analyze on a map?

This post originally appeared in the SAS blog The SAS Training Post.

Robert Allison, The Graph Guy!, SAS

Robert Allison has worked at SAS for more than 20 years and is perhaps the foremost expert in creating custom graphs using SAS/GRAPH. His educational background is in computer science, and he holds a BS, MS, and PhD from North Carolina State University. He is the author of several conference papers, has won a few graphic competitions, and has written a book calledSAS/GRAPH: Beyond the Basics.

Is Your City in the Path of the Total Eclipse?

Where will you be on August 21, 2017 when a total eclipse of the sun passes over much of the continental US? Here's a map to show you where you should go if you want to see it.

Risks to US Employment: Automation and Offshoring

Automation and offshoring are frequently discussed as threats to US employment rates. Here's a data visualization that shows the impact.