Data visualization with SAS programming

Creating a Map with a Reason Code and City Location

Reply
Contributor
Posts: 39

Creating a Map with a Reason Code and City Location

[ Edited ]

I have a dataset like this (truncated for this post):

 

data want;
input State $2. Setout_Code $3. Count_of_Code 3.;
datalines;
AR AB 14
AR BR 1
AR BT 10
AR DG 1
AR HB 1
AR KR 4
AR TB 1
AR TL 3
AR TR 1
AZ AB 6
AZ BR 2
AZ BT 19
AZ HB 1
AZ KR 2
AZ TL 5
AZ WP 5
CA AB 5
CA BG 2
CA BR 2
;
run;

 

In a separate program, Tableau, I've been able to project these values onto a map like such:

 

setout map.png

 

I'm trying to recreate this map in a smiliar manner in SAS, but cannot figure out how.  This is as close as I'm getting:

sasmap.JPG

 

The code i'm using to generate this in SAS is:

proc gmap data=work.want map=maps.us (where=(statecode not in ('PR' 'AK' 'HI')));
id STATE Setout_Code;
area STATE / nolegend;
block Setout_Code;

run;

 

Can someone help or point me in the direction of a method/options/different proc that will get me closer to generating a map like Tableau?  In the future, there might be need for also mapping out cities where these 'Setout_Code' counts are occurring, and I would potentially like to map those out on the same sort of US map of states (but specific to the city with each setout code colored separately).

 

Again, note that for this post's sake the data has been truncated, so both maps are showing the additional data I have in SAS.

 

Thanks

Grand Advisor
Posts: 16,420

Re: Creating a Map with a Reason Code and City Location

Note that I've moved this post to the graphics forum. 

Here's a recent blog post to get you started, but there are also more shown lately on the blogs so I'd read through there first as a starting point Smiley Happy

 

http://blogs.sas.com/content/sastraining/2017/03/21/create-pretty-map-proc-sgplot/

Grand Advisor
Posts: 9,748

Re: Creating a Map with a Reason Code and City Location

I am trying to understand the connection between the Tableau map and the SAS map. In Tableau you apparently have one value, or summarization per state applied at a single location to set the radius of a dot. In SAS you have, at least in some areas, multiple points with a block for each but I am not sure what the block represents or how it is placed as you aren't showing anything that I recognize that should make multple blocks per state.

 

If you are attempting to do something closer to the Tableau appearance then you likely want something with most of the information displayed with an annotate data set.

You may want to visit this page and see if something is close to what you want.

http://support.sas.com/sassamples/graphgallery/PROC_GMAP.html

 

 

Contributor
Posts: 39

Re: Creating a Map with a Reason Code and City Location

Thanks,

 

The tableau output is just an example of what I'm hoping to achieve in SAS.  Of all the SAS forums/pages/blogs/info (like the one you linked to) I cannot for the life of me figure out how to try to apply my SAS dataset and code, and use 'anno' or 'annotate' to overlay data onto a map.

 

Is there a good starting point for anno/annotate and how that works with graphs?  I was turning myself in circles when i tried searching for that from a 'beginners' POV.

Grand Advisor
Posts: 9,748

Re: Creating a Map with a Reason Code and City Location

The key bits with an annotate approach is 1) getting your locations specified IN THE SAME coordinate system as the map data set you will use and then creating a data set that attaches text, color, symbol what have you at those locations. Then setting the appropriate base map options and display.

 

The classic starter example is at: https://v8doc.sas.com/sashtml/gref/z0n01-ex.htm which places a symbol at the location of three cities on a US map.

 

Note that there are a number of macro statements, look up %annomac in your online help, to make repetive statments, like setting color and size based on values in your data set, easier.

 

It may be worth wondering around on http://robslink.com/SAS/ as there are many examples. The main pages show a number of graphs and clicking on title or picture takes you to a choice of code or the result. These are a good place to look for similar graphs as he provides data and some documentation.

 

Note that if you are attempting to do drilldowns that is possible but adds a lot of complexity.

 

 

 

 

SAS Employee
Posts: 963

Re: Creating a Map with a Reason Code and City Location

Grand Advisor
Posts: 16,420

Re: Creating a Map with a Reason Code and City Location

Just an FYI - the equivalent software to Tableau is not SAS Base but SAS Visual Analytics. 

 

Base will allow you to get close but it's definitely a lot more work than Tableau.

Post a Question
Discussion Stats
  • 6 replies
  • 140 views
  • 0 likes
  • 4 in conversation