BI Tools

Tips and tricks for building information maps, OLAP cubes, reports, and dashboards

BI Admin

Learn your way around a SAS BI installation.

Visual Analytics

Learn your way around the SAS Visual Analytics tool

Coding & Data

Extract, transform, and load your data into the SAS BI toolset

Stored Processes

Create and design stored processes like a rock star

Home » Data Visualization, Featured, Visual Analytics

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

Submitted by on 2016-07-31 – 11:52 AM

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.

va_param04b

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.va_param05

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.

  1. 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.]

    data parameter_example;
    input cat1 $ cat2 $ cat3 $ cat4 $ num1 ;
    cards;
    A X  X  X  0.21
    B X  X  X  0.25
    C X  X  X  0.29
    D 2a X  X  0.81
    E 2b X  X  0.89
    F X  3a X  0.41
    G X  3b X  0.49
    H X  X  4a 0.01
    I X  X  4b 0.06
    J X  X  4c 0.09
    ;
    run;
  2. Open the SAS VA Designer, start a new report and add the Parameter_Example data source.
  3. Create a new character parameter call Parameter 1.
    va_param01
  4. Right-click on the cat1 data item and select New custom category called Custom Cat VA.
    Your category should look like the following example when complete:
    va_param02
  5. Add a new calculated item called Calc Item.
    Your item should look like this following item when complete:
    va_param03
  6. Create your report layout as follows:
    • Add a button bar to the section area.
      • Assign the following roles:   Category = Custom Cat VA; Parameter = Parameter 1
    • Add a bar chart to the design area:
      • Assign the following roles:  Category = Calc Item; Measure = Num1
  7. Try it out!

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.

The following two tabs change content below.

Tricia Aanderud

Director of Data Visualization at Zencos Consulting
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.

Tags: ,