SAS Bar Chart – Explore the Different Types of Bar Charts in SAS

Previously, we learned about SAS Histogram, now we will look at the SAS bar chart. We will learn how to create a bar chart in SAS Programming Language and the different types of SAS bar charts: SAS simple bar chart, SAS stacked bar chart (SAS grouped bar chart), and SAS cluster bar chart (SAS bar chart side by side).

So, let’s start the tutorial.

SAS Bar Chart

Stay updated with latest technology trends
Join DataFlair on Telegram!!

What is Bar Chart in SAS?

SAS bar chart shows the distribution of a categorical variable. The bar chart in SAS is some of the most commonly used graphs to convey information to the reader. Bar charts are used across all domains, including business, finance, banking, clinical and health, and life sciences.

Below is what a typical SAS bar chart looks like:

Example 1-

SAS Bar Chart Example 1

Example 2-

SAS Bar Chart Example 2

The PROC SGPLOT Procedure

The basic syntax to create a SAS bar chart is:

VBAR variables;

PROC SGPLOT is used to create a bar chart in SAS.
A VBAR statement is used to create a vertical SAS bar chart of the variable.

Must Learn – SAS Variable

SAS Simple Bar Chart

A simple bar chart in SAS is the one that has single vertical bars. We have used the Olympics data set. This SAS Bar chart shows the number of countries in each region that participated in the 2012 Olympics.

PROC SGPLOT DATA = olympics;
 VBAR Region;
TITLE 'Olympic Countries by Region';


SAS Bar Chart

SAS Stacked Bar Chart

In this type of SAS bar chart, a variable’s value is represented with respect to another variable. Here, the bars have been divided into groups using the GROUP= option. The grouping variable is a categorical variable named PopGroup. By default, SAS creates stacked bars.

PROC SGPLOT DATA = olympics;
VBAR Region / GROUP = PopGroup;
TITLE 'Olympic Countries by Region and Population Group';


SAS Bar Chart

Do you know? – How to Enter and Read Raw Data in SAS Programming

SAS Clustered Bar Chart

Like in the previous example the groups were stacked one above the other, the variables can be stacked next to each other that is side by side. You can specify side-by-side groups instead of stacked groups by adding the option GROUPDISPLAY = CLUSTER to the VBAR statement.

PROC SGPLOT DATA = olympics;
TITLE 'Olympic Countries by Region and Population Group';


SAS Clustered Bar Chart

This comes to the end of the tutorial.


We hope you understood the different types of SAS bar charts. If you have any queries, feel free to ask in the comment section.

Explore the lucrative career opportunities in SAS programming

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google | Facebook

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.