Data visualization with SAS programming

Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

Accepted Solution Solved
Reply
Highlighted
Community Manager
Posts: 3,355
Accepted Solution

Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

[ Edited ]

Hello Graph enthusiasts!

 

I thought you'd like to know about this new feature in Base SAS (introduced in 9.4 Maint 5) -- you can now create map charts with ODS Graphics!  The new SAS procedure is called SGMAP.

 

Turbines-200-MW.jpgSGMAP chart using OpenStreetMaps

 

SAS mapping expert Ed Odom (@EdO_sasintroduces the feature on this blog post.  It has a super cool, elegant syntax:

 

proc sgmap plotdata=US_GT_200MW;
     openstreetmap;
     bubble x=long_num y=lat_num size=MW_total;
run;

 

Like most data analysis work, the heavy lifting is in the data prep.  But once you have the response values and coordinates lined up the way that you need them, adding a map is simple.

 

With the recent update to SAS University Edition, anyone can try out this new feature, even if you don't yet have SAS 9.4 Maint 5 at your workplace.  Give it a try!


Accepted Solutions
Solution
‎02-03-2018 11:41 AM
SAS Super FREQ
Posts: 1,046

Re: Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

Hey Tom,

 

This turns out to be a font issue. SAS UE ships with a limited number of fonts to keep the install size small. It turns out that the default ODS styles associated with PDF and RTF are referencing fonts that are not there. Currently, the map renderer is having issues when that fonts cannot be found. To work around this, go into the SAS UE preferences, under the "Results" tab, and change the ODS styles for PDF and RTF to be the same as HTML5 (which is "HTMLBlue"). Other styles might work as well -- just give them a try. We'll get this issue resolved as soon as possible.

 

Hope this helps!

Dan

View solution in original post


All Replies
Frequent Contributor
Frequent Contributor
Posts: 89

Re: Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

Posted in reply to ChrisHemedinger
Very cool-will definitely check this out!

One question. This is a departure from the current ODS Graphics model, in which various plot types are specified with statements within more general procedures. For example, others have cleverly shown how a POLYGON statement can be used with PROC SGPLOT to create maps (albeit with a lot more "elbow grease" and projected map data!). And by extension, a POLYGONPLOT statement can be used with PROC SGPANEL to make panels of maps. Is there currently a way, or will there be a way, to create paneled SGMAP-type maps?
SAS Super FREQ
Posts: 1,265

Re: Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

We are looking into it.  I would encourage you to report this matter into Tech Support to get it into the formal process.

Super User
Super User
Posts: 7,850

Re: Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

[ Edited ]
Posted in reply to ChrisHemedinger

I tried to replicate one of the maps in the documentation.  I am able to view the graph in the HTML output, but I also get error messages in the log and the PDF and RTF output do not have any graph.

 

I generated the datasets using SAS 9.4M3 and downloaded them to SAS UE and tried to replicate the graph.

 

libname mymaps '/folders/myfolders/sgmaps_example';
proc sgmap mapdata=mymaps.nevada     
           plotdata=mymaps.city_pop_xy 
           des='Nevada'
;
  title 'Nevada County Seat Populations';
  choromap / mapid=county;
  bubble x=x y=y size=population_city 
   / name='cities' datalabel=city
     datalabelattrs=(color=red size=9 style=italic)
  ;
  keylegend 'cities';
run;

Here are the error messages. 

 NOTE: CHOROMAP statement is pre-production for this release.
 NOTE: PROCEDURE SGMAP used (Total process time):
       real time           1.73 seconds
       cpu time            0.88 seconds
       
 ERROR: Physical file does not exist, /tmp/SAS_work0C4F000019C2_localhost.localdomain/_9C8E41015DA3C4EAFFAF7CE05957187.png.
 ERROR: Physical file does not exist, /tmp/SAS_work0C4F000019C2_localhost.localdomain/_9C8E41015DA3C4EAFFAF7CE05957187.png.
 ERROR: Physical file does not exist, /tmp/SAS_work0C4F000019C2_localhost.localdomain/_EFDB80C0F401C498835C83B07ABA51D.png.
 ERROR: Unable to load image 
        /tmp/SAS_work0C4F000019C2_localhost.localdomain/_EFDB80C0F401C498835C83B07ABA51D.png?width=1000px&height=750px&desc=Nevada; 
        default image will be used instead.
 ERROR: Unable to read the default image. No image will be produced.
 NOTE: There were 17 observations read from the data set MYMAPS.CITY_POP_XY.

I can prevent the errors by excluding the output from PDF and RTF destinations.

ODS RTF (ID=WEB) exclude all ;
ODS PDF (ID=WEB) exclude all ;

Is this because it does not work with PDF and RTF?

Or is there some other reason it doesn't work with these destinations?

 

 

Solution
‎02-03-2018 11:41 AM
SAS Super FREQ
Posts: 1,046

Re: Introducing PROC SGMAP: create map charts in Base SAS, SAS University Edition

Hey Tom,

 

This turns out to be a font issue. SAS UE ships with a limited number of fonts to keep the install size small. It turns out that the default ODS styles associated with PDF and RTF are referencing fonts that are not there. Currently, the map renderer is having issues when that fonts cannot be found. To work around this, go into the SAS UE preferences, under the "Results" tab, and change the ODS styles for PDF and RTF to be the same as HTML5 (which is "HTMLBlue"). Other styles might work as well -- just give them a try. We'll get this issue resolved as soon as possible.

 

Hope this helps!

Dan

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1040 views
  • 3 likes
  • 5 in conversation