Need a Dynamic X-Axis with Your SAS Visual Analytics Report?

I like to read the SAS Visual Analytics area of SAS Communities site. From the site I have overcome issues I had as well as learned other ways to think how you can solve common issues. As many long time SAS users know – there’s always more than one way to accomplish something with SAS! Recently, as user was asking how to expand parameters to create a dynamic x-axis. Using his partial example, here’s how it can be done.

Creating a Dynamic X-Axis

The user wanted the X-Axis on his chart to change based on the button bar selection. Notice that when I click on each button, the X-Axis values change based on my selection.If I click cat2 then the x-axis shows the 2a and 2b instead of the ABC values from cat1.

You can use a parameter to accomplish this task. The parameter can pass the desired category to the Category role. Here’s the sample data set that I used to create this graphic. In my example, I will use cat1 to create a custom category. Then the custom category will control the rows and the selected data item.

If you click the cat2 button, it filters the data to show rows 4 and 5. With the parameter, it says display the values from cat2 data item. Study the data and then the graphic above to better understand what is being displayed. Remember – using this method is pre-filtering the data!

Adding a Parameter

Here’s how I setup this example. You try it.

Run the following program in BASE SAS, SAS Studio, or even SAS Enterprise Guide. It creates a data set called parameter_example.
[Or you download the text file version and import it as a text file into SAS Visual Analytics, if allowed at your site.]

You could also use this method with a measure. If you wanted to change the chart to show the minimum value or the maximum value – you could do it with the click of the button. I’ll let you work that one out for yourself.

Hustle over to the SAS Communities page to see what you can learn!

Never miss a BI Notes post!

Click here for free subscription.
Once you subscribe you'll be asked to confirm your subscription through your email account.
You email address is kept private and you can unsubscribe anytime.

Tricia Aanderud is a SAS Business Intelligence and Visual Analytics consultant based in Raleigh, NC who works for Zencos Consulting. She has written several books about SAS, presented papers at many SAS conferences, and has been using SAS since 2001. Contact her for assistance with your next project.