BookmarkSubscribeRSS Feed

How to place 4 measures on the same SAS Visual Analytics graph

Started ‎09-18-2015 by
Modified ‎04-29-2016 by
Views 8,779

Visualizing multiple metrics on the same graph is something of great value. There are many ways to see how one measure relates to another in SAS Visual Analytics’ stock graph objects. Examples of two measures on the same chart include the “Dual Axis Bar Chart,” “Dual Axis Line Chart,” and “Dual Axis Bar-Line Chart” objects. An example of having three measures on one plot is the very popular “Bubble Plot.”


While these are all great examples, there are times when the report designer needs to “up the ante” and create a graph object that displays four measures simultaneously. This task can be difficult, because it is not easy to include this many measures while not confusing the report consumer.


Fortunately, there’s a great example of how to achieve this using PROC SGPLOT. As part of the SAS Visual Analytics Community custom graph sharing initiative I’ll tell you about how to create this graph in this post.




In this example, a regular butterfly plot is customized to have ‘bars within the bars’ to add two extra measures to the graph.  Pretty nifty! 


The next question is, how can we replicate this in SAS Visual Analytics?  It’s fairly easy once you start using the VA Graph Builder from the right panel in VA Home (look for Custom Graph) or from the object tab in the left panel in VA Designer.




In Visual Analytics Release 7.1 there is a Butterfly Chart available in the “New Custom Graph” gallery.  From this gallery that is on the initial page, scroll down and select the “Butterfly Chart” graph.




You now have the basis for your new plot.  The first step to creating the ‘bars within bars’ effect is to drag a new bar chart from the “Graph Elements” panel on the left to the bar chart on the left of the butterfly.



Now that we have overlaid the new bar chart onto the left bar chart, we will need to make its bars narrower so they will fit inside the bars on the original bar chart.  This is achieved by selecting the ‘Properties’ tab on the right.  Scroll down and change the “Bar Spacing” slider to a value of 0.55.  This will achieve the desired “bar inside bar” look. 


Also, since we want to have the colors of the two overlaid bar charts be identical, we will need to edit a second option.  This is the “Fill Color” drop down.  Change this to match the bar color of the bars on the original bar chart.  In this case, the bar colors are “Data Color 1.”  Both correctly-set options are shown below:



The final step to make our bar chart look like the PROC SGPLOT example is to increase the transparency of the original bar chart.  In order to do this, first select the “Bar Chart 1” graph object from the top dropdown of the “Properties” panel.  Once “Bar Chart 1” is selected, change the value on the “Transparency” slider to ‘0.50.’  This will create the ‘light’ look for the back bars on the plot.



You now have completely replicated half of the example from the PROC SGPLOT example!  Duplicate the same steps for the bar chart on the right, and you will have recreated the entire plot!


The final step is to use your graph in a report.  Use the code from the example at (under the 'Full Code' tab) to create the data for the plot.  Be sure this data is available in SAS Visual Analytics Designer and to rename the data items that come with the data as shown below:



Rename the data items as:

  • cause – Cause
  • deaths – Deaths
  • fcases – New Cases (Female)
  • fdeaths – Deaths (Female)
  • mcases – New Cases (Male)
  • mdeaths –Deaths (Male)

Also change for format for all these measures to be Comma in the measure properties.


Place your newly created custom graph on the report canvas and map the data to the graph as shown in the “Roles” tab on the right of the screenshot below:



And you’ve done it!  You’ve replicated the plot from in SAS Visual Analytics!  The added benefit of course is having the dynamic capabilities of SAS Visual Analytics enabled on your graph. 


How to make the example work for you:


This example was created in SAS Visual Analytics 7.1.  Attached is a SAS package file containing the custom graph template and sample report.  Again, use the code in create the sample data to feed the visualization.  Load this same data into memory on your Visual Analytics instance and you will be able to import this package if you have access to the SAS Management Console 7.2. Please refer to these instructions




If you are unable to load the data from the example into memory, you can alternatively import the CANVER.csv file that is packaged with this example.


If you do not have access, contact your SAS Visual Analytics Administrator.  Be sure to select the report and the custom graph.


Think you’ll give this a try? Tell us about your project, and share you own custom graph examples on the community!



This is amazing! Never knew that cool trick to add the bars inside the butterfly chart.

Great, so glad you found this helpful!

Hi this looks great. I know this can be creaded by codes as well .So before i try to build the code, may i ask you if you have the code for it ?



I'm not sure I understand what code you are looking for.  If you mean the code to build the example data, it can be found in the original SG Plot example: ( under the "Full Code" tab. 


However, if this is not the code you are looking for, please let me know!

Hi Mike ,


Thanks i was looking for this .






Version history
Last update:
‎04-29-2016 10:20 AM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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