Bar Chart Task

About the Bar Chart Task

The Bar Chart task creates horizontal or vertical bar charts that compare numeric values or statistics between different values of a chart variable. Bar charts show the relative magnitude of data by displaying bars of varying height. Each bar represents a category of data.

Example: Bar Chart of Mean Sales for Each Product Line

For example, you can create a bar chart that compares the total amount of sales for each product line in the Sashelp.Pricedata data set. By default, the task calculates the mean of the response variable for each product line. This bar chart shows that Line 2 has the highest mean product sales.
To create this example:
  1. In the Tasks section, expand the Graph folder and double-click Bar Chart. The user interface for the Bar Chart task opens.
  2. On the Data tab, select the SASHELP.PRICEDATA data set.
  3. Assign columns to these roles:
    Role
    Column Name
    Category variable
    productLine
    Response variable
    sale
  4. To run the task, click Submit SAS code.
Here are the results:
Bar Chart That Displays Sales for Each Product Line

Assigning Data to Roles

To run the Bar Chart task, you must assign a column to the Category variable role.
Role
Description
Category variable
specifies the variable that classifies the observations into distinct subsets.
Response variable
specifies a numeric response variable for the plot.
Group variable
specifies a variable that is used to group the data.
URL variable
specifies a character variable that contains URLs for web pages to be displayed when parts of the plot are selected within an HTML page.
BY variable
creates a separate graph for each BY group.

Setting Options

Option Name
Description
Direction
You can create either a vertical or horizontal bar chart.
Title and Footnote
You can specify a custom title and footnote for the output.
Group Layout
Cluster
displays group values as separate adjacent bars that replace the single category bar. Each set of group values is centered at the midpoint tick mark for the category.
Stack
overlays group values without any clustering. Each group is represented by unique visual attributes derived from the GraphData1... GraphDatan style elements in the current style.
Statistics
Mean
calculates the mean of the response variable.
Sum
calculates the sum of the response variable.
Limits
Limits
specifies which limit lines to display. Limits are displayed as heavier line segments with a serif at the end that extends from each bar. Limit lines are displayed only if you select the Mean statistic.
Limit statistic
specifies the statistic for the limit lines.
Limit multiplier
specifies the number of standard units for the limit lines. By default, this value is 1.
Bar Details
Apply bar color
specifies the color for the bars when a column is not assigned to the Group variable role.
Transparency
specifies the degree of transparency for the plot. The range is 0 (completely opaque) to 1 (completely transparent).
Data skin
specifies a special effect to be used on all filled bars.
Bar Labels
Show bar labels or statistics
displays the values of the calculated response as data labels.
Category Axis
Reverse
specifies that the values for the tick marks are displayed in reverse (descending) order.
Show values in data order
places the discrete values for the tick marks in the order in which they appear in the data.
Show label
enables you to display a label for the axis. Enter this label in the Custom label box.
Response Axis
Show grid
creates grid lines at each tick on the axis.
Append statistics to axis label
includes the name of the calculated statistic in the axis label. For example, if you are calculating the mean, the axis label could be Weight (Mean).
Custom Label
enables you to customize the label for the response axis. By default, the axis label is the name of the variable.
Legend Details
Show legend
specifies whether to display a legend in the output.
Legend location
specifies whether the legend is placed outside or inside of the axis area.
Graph Size
You can specify the width and height of the graph in inches.