Using 3rd party shape files to build map charts in SAS


While talking to SAS users in Australia earlier this month, I often demonstrated the capabilities of the new Map Chart task in SAS Enterprise Guide 4.3. Creating map charts has never been easier: select your map data source, then select your response data source, and click Run. Voila! You've got a map chart.  (See this SAS Global Forum paper from Stephanie Thompson for proof that it's "easier than you think".)

Of course, all of my map chart examples used data from the United States.   Australians recognize a map of the USA when they see it (I cannot say the same of many Americans who view a map of Australia), but they wanted to see examples of maps that featured their country. And although SAS provides map data for Australia with detail to the state level, these users wanted more detail than that.   Here is an example of a "coarse-grained" map chart of Australia with just the state boundaries, created using the MAPS.AUSTRAL data set that is supplied with SAS:
Not much detail in this map of Australia

On their web site, the Australia Bureau of Statistics provides map data with more details, down to the "statistical regions", "local government regions" and more. These data files are provided as shape files in ESRI or MapInfo format.

Fortunately, it's easy to import ESRI shape files into SAS map data sets by using PROC MAPIMPORT.  Assuming you've downloaded the ESRI shape files to your local system, this simple code can convert them to a SAS map data set:

/* Shape file for statistical local areas */
proc mapimport out=aus_sla

With the map data now available in WORK.AUS_SLA, all you need is some response data that contains a shared identifier field.  The following step creates a data source with random values:

/* make up some response data */
data response_sla;
  set aus_sla (keep=SLA_CODE11 SLA_NAME11);
	/* keep just one value per region */
	by SLA_CODE11;
	if first.SLA_CODE11;
	/* random value between 0 and 100 */
	RespValue = ranuni(0) * 100;

Now use the GMAP procedure to combine the two data sources into a colorful, if somewhat meaningless, map of Australia:

/* create a simple map chart by combining the two */
legend1 across=3 label=("Values");
goptions colors=(green blue purple red orange yellow );
proc gmap data=work.response_sla map=work.aus_sla all;
	id sla_code11;
	choro RespValue / levels=6

Here is a sample of the output (Americans, take note):
A sample map chart with more detail for Australia

Just remember: Map Charts = Map Data + Your Response Data.  With a third data set for annotations, you can create even fancier results.  But that's a topic for another blog post.  For those readers who are curious in the meantime, a simple SAS support search will open the door for you.



About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. Michelle Homes on

    Great article and thank you for localising it too. I didn't know the ABS provide the ESRI shape files for the Australian Statistical Local Areas. Will definitely be sharing this blog post. Thanks!

  2. This will be appreciated greatly by Australian SAS users. I wonder if we could further localise the map to a single State Level?

    • Chris Hemedinger
      Chris Hemedinger on

      I think that reducing the map to just a subset (by subsetting the MAP data set to contain just the information for a single state, based on state code) would do the job.

  3. Louise Hadden on

    Handy tips - I just gave a paper at MWSUG 2016 and SGF 2017 on this very topic,! There's quite a bit of data to be had at the Australian postal code level and many cities, towns and larger entities are creating data farms with municipal data. With PROC MAPIMPORT, the sky, and beyond, is pretty much the limit. In the paper, I demonstrate using PIGWAD data and shape files to map Mars. I have to put in a plug for SAS MapsOnline There is so much useful information and data, including British geocoding. In addition, Robert Allison of SAS has an amazing site with samples galore (including code and free ebooks to help you get started.) Happy Mapping, all.

Back to Top