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 426

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