More than just Statistics – Can we Map in SAS?

PDF copy of the SAS syntax file used for this session.

We say SAS – we think statistics!  We think statistics – we say SAS!  We think maps and GIS – SAS is probably the last program you think to use.  There are so many other options out there, why would you use SAS?  Well…  believe it or not, but you can create basic maps with values in SAS.  Unfortunately, if you are using University Edition – SAS Studio – you do not have access to the PROCedures needed to create maps in SAS.

This blog post is based on a workshop delivered at the SUGI conference in 2004.  The data has been updated to use the 2016 and 2011 Canadian Census of Population.  Let’s get started and create 3 maps to demonstrate some of the options available in the PROC GMAP.

First thing that you need to know, is that SAS has a large selection of maps built-in.  If you browse the SAS system, you will see a library called MAPS.  If you browse in this library – you will see a large selection of maps from around the world.  We will take advantage of these in our session.

First map – using the choropleth

We will use the population of each province – with the exception of Nunavut, and create a choropleth map showing the distribution of population in 2016.

/* Reset all graphics options to default values */
goptions reset=all;

/*  Create a choropleth map with a tite  */
Proc gmap data=canada_pop map=maps.canada2;
  id province;
  choro pop_2016;
  title “Canadian Population by Province, 2016”;
  title2 “Using the Choropleth”;
Run;
quit;

PRoc GMAP – calls on the GMAP procedure, also note that you need to specify the dataset that you are using – contains the population – and the map what you will be applying the data to.  MAPS.CANADA2 is one of the internal maps created in SAS.

The ID statements is linking the variable called ID in the dataset and on the map.  The values of the ID variables have to be the same in both the data and the map.  We know that SAS used the province IDs that Statistics Canada uses.  To determine what the ID variable is on the MAPS – in SAS – open the datafile associated with the map you will be using.

CHORO – is calling on the GMAP procedure to add the 2016 population onto the map.  Without any options on the CHORO line, SAS will create the groupings – 4 by default on our map.

Second map – displaying prisms

Our second map will display prism.  This is a 3-D view of the relationships between our groups.  A larger value of our data will display a higher cutout.

/* reset all graphics options to default values */
goptions reset=all;

/* Create a prism map with a title and footnote */

Proc gmap data=canada_pop map=maps.canada2;
    id province;
    prism pop_2016;
    title “Canadian Population by Province, 2016”;
    title2 “Using Prisms”;
Run;
Quit;

Now we will use the PRISM option rather than CHORO.  Try it out and see what the results are.  Here is a link to a resulting map in PDF form.

Third map – using blocks

Our third map will display a block in each province that depicts the population.  The height of the block relates directly to the value of the population.

/* Reset all graphics options to default values */
goptions reset=all;

/* Create a block map with a title and a footnote */
Proc gmap data=canada_pop map=maps.canada2;
    id province;
    block pop_2016;
    title “Canadian Population by Province, 2016”;
    title2 “Using Blocks”;
Run;
Quit;

Changing the PRISM line to BLOCK in this example will give us our third map.

Conclusion

This was a brief overview of how we can incorporate mapping features into SAS.  We have only seen the very basic maps available in PROC GMAP.  We tend to use other GIS mapping software packages to create GIS maps, but be aware that we can use SAS.  Another option available with PC-SAS, is the GIS ESRI bridge, this option provides a bridge between one of the most popular GIS programs, ESRI, and SAS.

Screen Shot 2013-11-18 at 7.33.07 PM

 

One thought on “More than just Statistics – Can we Map in SAS?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s