SAS - Bar Charts

A bar chart represents data in rectangular bars with length of the bar proportional to the value of the variable. SAS uses the procedure PROC SGPLOT to create bar charts. We can draw both simple and stacked bars in the bar chart. In bar chart each of the bars can be given different colors.

Syntax

The basic syntax to create a bar-chart in SAS is −

PROC SGPLOT DATA = DATASET;
VBAR variables;
RUN;

Following is the description of parameters used −

DATASET − is the name of the dataset used.

variables − are the values used to plot the histogram.

Simple Bar chart

A simple bar chart is a bar chart in which a variable from the dataset is represented as bars.

Example

The below script will create a bar-chart representing the length of cars as bars.

Clustered Bar chart

The clustered bar chart is created to show how the values of a variable are spread across a culture.

Example

The below script will create a clustered bar-chart where the length of the cars is clustered around the car type.So we see two adjacent bars at length 191, one for the car type 'Sedan' and another for the car type 'Wagon'.