BookmarkSubscribeRSS Feed

3 steps to build a US map tile chart in SAS Visual Analytics

Started ‎03-04-2019 by
Modified ‎03-04-2019 by
Views 1,912

Have you ever wanted a more unique way to display US state data in a SAS Visual Analytics report?  For example, when using the Geo Map report object and wanted to display more than one metric on it?  This can be difficult using a standard VA Geo Map: if you use a bubble map you can only have one bubble per state and only one metric can determine the bubbles' size.  Similarly, if you use a region map, you can only use one metric to determine the gradient color of each state's region. 

 

Recently, I was building a SAS Visual Analytics report using data from this Curriculum Pathways Data Depot resource which examines number of deficient bridges in the U.S. from 2013 to 2015. I needed to show TWO metrics for each state on a US map.  One metric was the amount of bridge surface area that is not considered deficient.  The other metric was the amount of bridge surface area that is considered deficient.  After attempting several versions of my VA report using the Geo Map report object, I decided to take my report in a different direction.  Using a custom graph, I was able to build the following visualization of the United States which displays both these metrics:

 

US_MAP_TOP_PRD_BDR_ORIG.png

 

The report above shows a series of data tiles that are arranged to look like the US map.  Each tile represents a US state and its its associated abbreviation.  Most importantly, each tile show TWO metrics, the percent of deficient vs. non-deficient bridge surface area.  This solves the issue of wanting to show more than one metric on a map of the US States. 

 

Building this report was easy using the SAS Graph Builder in the Viya Platform.  So easy, that in this article, I'll show you how to build this yourself!

 

Step 1: Build the graph

 

Start by creating a new custom graph using the graph builder.  First, drag three Schedule Charts onto the reporting canvas and place them on top of each other:

 

01.png

 

Next select the options menu on the left and from the drop down select "Schedule Chart 3".  Slide the "Spacing" slider all the way to the right:

 

B01.png

 

 

Still within the options menu, select "X Axis" and select the "Off" option in the Grid Lines drop-down.  Also UNCHECK all other options in the menu.:

 

B02.png

 

From here still within the options menu, select "Y Axis" and select the "Off" option in the Grid Lines drop-down.  Also UNCHECK all other options in the menu.

 

The next thing to do is to edit our roles.  From the left sided menu switch over to the "Roles" menu and for the following graph elements add these roles:

 

  • Bubble Plot 3
    • Role Type: Data Label
    • Role name: Bubble Plot 3 Data Label
    • Classification: Any classification

Next, right you will need to create a new shared using the existing roles "Schedule Chart 3 Start" and "Schedule Chart 3 Finish": 

 

B04.png

 

Name this new shared role "Label".

 

And you're done!  You've successfully built the custom graph.  Save your graph and give it a name.

 

Step 2: Prepare your data

 

The data preparation for this graph is fairly straightforward.  First a matrix is needed that places each US state in its appropriate position on the map/tile chart.  For example, the following states need to be in the following positions:

 

  • Hawaii
    • Row 1
    • Column 1
  • Alaska
    • Row 8
    • Column 1
  • Kansas
    • Row  3
    • Column 3

Since we are using a schedule chart base for this custom graph, the "Row" will be the schedule chart's "Task" and the column will be the schedule chart's "Start" and "Finish".  This post has a data set which already has the states in the needed positions for this matrix.  Also, in order to place the US State abbreviation on each tile, a value will need to be in place onto which the label will be placed. 

 

To simplify this process, a SAS data set template is attached to this post that already has the US states and their needed values for positioning and labels.  Since there are several tiles on the canvas that don't have a state on them, the data has several observations that are 'missing'.  A subset of this data set template is displayed below:

 

B05.png

 

The next step is to join the deficient bridges data to this data set template.  A subset of the bridges data set is shown below:

 

D3.png

 

The following code will join this data set to the data template:

 

 

proc sql;
create table add_data_values as select
t1.*,
t2.Surface_Area_Def_Bridges2015,
t2.Surface_Area_Tot_Bridges2015
from src.US_MAP_infographic_data_template as t1 full join
src.deficient_bridges as t2
on (upcase(t1.statename)=compress(upcase(t2.state),"ABCDEFGHIJKLMNOPQRSTUVWXYZ " ,"kis"))
where t1.row ne "";
quit;

 

 

We will now need to create the start and finish values for the first and second schedule charts.  The first schedule chart will represent the amount of bridge surface area that is not considered deficient.  We first need to calculate what percent of the overall surface area this represents.  Then using that percentage, we will calculate the start and end values for the first schedule chart to match that same population.  Similarly, we will do the same for the second schedule chart which will represent the percentage of deficient bridge surface area.  The code to do this is below:

 

 

data deficient_bridges_infographic;
set add_data_values;
Surface_Area_Def_pct = Surface_Area_Def_Bridges2015/Surface_Area_Tot_Bridges2015;
Surface_Area_good_pct = (Surface_Area_Tot_Bridges2015-Surface_Area_Def_Bridges2015)/Surface_Area_Tot_Bridges2015;
format Surface_Area_Def_pct Surface_Area_good_pct percent8.2;
schedule_chart1_start = start;
schedule_chart1_finish = (((finish-start)*Surface_Area_good_pct)+start);
schedule_chart2_start = (((finish-start)*Surface_Area_good_pct)+start);
schedule_chart2_finish = finish;
run;

 

 

 

And that's it!  The data values for the deficient bridge surface area have been added to our data template.  More so, the appropriate start and finish values for both the deficient surface area and non-deficient surface area have been created.  A subset of the final data set is below:

 

D2.png

 

Step 3: Build the report!

 

All that's left for us is to import the custom graph to a Visual Analytics report. 

 

Add the data set 'deficient_bridges_infographic' to your report and apply the roles as shown:

 

r4.png

 

You will also need to adjust a property at the report level. To do this click the white space at the very top of the page (above the tab for the report) and select the options menu. This will allow you to change report-level properties.

 

In order to have the labels for the state abbreviations be large, I created a new report theme using the SAS Theme Designer.  This theme is simply a copy of the "Aqua" theme that come out of the box with SAS Visual Analytics with the size of the base font being 24.  Also in the "Style" section change the third color in the "Fill" section to be the same as the first.

 

r2.png

 

And that's it! Add a title to your tab and you're report is complete!

 

US_MAP_TOP_PRD_BDR_ORIG.png

 

Additionally, I created a custom legend from a text object and placed it under the graph.  This legend  is included in the report's JSON file that is attached to this post.

 

How to make this example work for you

This example was created in SAS Visual Analytics 8.3.  Again, for this post's data, I used the Curriculum Pathways Data Depot resource.

 

The attachments for this post are:

  • The data set template which includes the state tiles in the correct positions  - US_MAP_infographic_data_template.sas7bdat
  • The ETL which add the deficient bridge data to the data set template and create the final deficient_bridges_infographic.sas7bdat dataset - deficient_bridge_ETL.sas
  • A JSON file containing the custom graph and report - US_MAP_infographic.json
  • The theme used to create the large text labels - Big_text_Theme.td

Import the data on your SAS Visual Analytics instance.  Import the report via the "Import via GUI" section of these instructions.  If you wish, you can also import and publish the theme using these instructions.

Version history
Last update:
‎03-04-2019 10:52 AM
Updated by:
Contributors

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags