SAS Communities Library

We’re smarter together. Learn from this collection of community knowledge and add your expertise.
BookmarkSubscribeRSS Feed

Overlaying positive and negative column charts with a line chart in SAS® Visual Analytics

Started ‎08-01-2024 by
Modified ‎08-13-2024 by
Views 658

You can display both positive and negative values for a time period (year) when displaying the number of new members and canceled members.

At the same time, you can add a line chart to view the trend of the total number of members, as shown in the image below.

 

You can use a chart to visualize this data by creating a custom graph template in SAS® Graph Builder, which you can then use in a SAS Visual Analytics report.

Custom Graph Template.png

 

 

To visualize the data, complete the following steps:

 

1) Build a custom graph template.

SAS Graph Builder enables you to create custom graph templates, which you can use in SAS Visual Analytics reports. In your graph template, you can change the layout, add new graph elements, modify data roles, change options, and so on.

 

To use SAS Graph Builder, from menu on the left pane, select Build Custom Graphs.

 

In order to create the graph above, the template consists of two bar charts and a line chart.

a) Select [New Custom Graph].

b) From the Elements menu on the left pane, drag the [Bar Chart] option twice and the [Line Chart] option once.

New Custom Graph.png

c) Click the Options menu on the right pane and select [Line Chart] from the drop-down list. Then, in the Y axis field, click Right.

Line Chart _ Y axis.png

d) Save the graph template as PN_Bar&Line

 

2) Prepare the sample data.

After building a graph template, you need to make sure that your data will work with it. You might choose to do either of the following:

  • Use existing data.
  • Create data using the SAS code provided below to load the data into SAS® Cloud Analytics Services (CAS).

DATA pnbarline;

  RETAIN totmem 100000;

  DO i=1 TO 20;

    newmem=1000*i;

    cancel=(500*i)*-1;

    totmem=totmem+500*i;

    _year=2003+i;

    year=mdy(12,31,_year);

    OUTPUT;

  END;

  DROP i _year;

  FORMAT year year4.;

RUN;

pnbarline.sas7bdat

 

3) Import the custom graph and build a graph in SAS Visual Analytics.

From the menu on the left pane, click Explore and Visualize to move to SAS Visual Analytics. In order to use the custom template in SAS Visual Analytics, you need to import the template by completing the following steps:

a) On the objects pane, click. Then, click Import custom graph and select your custom graph.

 

b) Choose the sample data and assign the roles as follows: 

 

The output should look similar to the following:

Custom Graph Template.png

Version history
Last update:
‎08-13-2024 04:08 PM
Updated by:
Contributors

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Labels
Article Tags