Doing More with Graphics |
You can use Bar Charts on the Graphics menu to create horizontal or vertical simple bar charts, stacked bar charts, grouped bar charts, and grouped and stacked bar charts. In the "Graphics" chapter of Getting Started with SAS/ASSIST, you learned how to create a bar chart. This section describes some of the more advanced options available when generating bar charts.
Generating a Bar Chart with the Mean Displayed |
In this section you create a vertical bar chart showing the mean weight by age in the CLASS data set. You choose to have the mean of each bar displayed above the bar, adjust the fill patterns of the bars, add a title to the chart, and change the font of the title.
To display the Bar Charts window, follow this selection path:Tasks Graphics Bar ChartsThe Bar Charts window appears.
Bar Charts Window
Select Bar values. The Bar/Slice Values window appears.
Bar/Slice Values Window
Select Mean as the statistic you want the bars to represent. By selecting Mean, each bar represents the mean of the analysis variable. You must select an analysis column if you select Sum or Mean as the bar value.
Select OK to return to the Bar Charts window.
Select Additional options. The Additional Options window appears.
Select General options. The General Options window appears.
General Options Window
Select Mean as the statistic to display above the bars for the vertical bar chart.
Select Color and pattern options. The Color and Pattern Options window appears.
Color and Pattern Options Window
For the 1ST and 4TH areas, select Cross as the pattern.
For the 2ND and 5TH areas, leave the pattern as Solid.
For the 3RD and 6TH areas, select Empty as the pattern.
The pattern selected by default for the bars is Solid.
If you print a color graphic, you can use colors to distinguish one bar from another. To display a list of valid colors, type ? in the first position of the Color field and press ENTER. Select the color you want to use.
Select Number of bars. The Midpoint Values window appears.
Midpoint Values Window
Select Use each discrete chart variable value. The Additional Options window reappears.
You select Use each discrete chart variable value to display one bar for each age represented in the CLASS data set (11, 12, 13, 14, 15, and 16). The default for the number of bars is Let the number of midpoints default, which lets the procedure determine the number of midpoints (bars) for the chart column. Each midpoint represents a median of a range of values. In this example, if you use Let the number of midpoints default, the bars represent the midpoints of the AGE variable (11.4, 12.6, 13.8, 15, and 16.2).
The window that appears when you select Number of bars is different for numeric and character chart columns.
To display the Title 1 window, follow this selection path starting from the Bar Charts window:Edit Titles Title 1
Title 1 Window
Type Mean Weight by Age as the title for the plot.
Note: Titles carry over from one report or graphic to another. If you do not type a title and a title was selected previously in the current SAS/ASSIST session, the previous title automatically appears on your graphic.
Select Font from the Title 1 window.
Font List Window
Select Italic as the font for Title 1; the Title 1 window reappears.
Select Submit from the Run menu. The bar chart appears in the GRAPH window.
Bar Chart Output
To return to the Bar Charts window from the GRAPH window, follow this selection path: File Close
Other Bar Chart Options |
By selecting 3D in the Bar Charts window, you can create three-dimensional bar charts, as shown in the following example.
Three-dimensional Bar Chart Output
By assigning a column to Stacking column or Grouping column, you can create bar charts that show more interesting relationship in your data. For example, if you assign the SEX column to Grouping column in the previous example, you create a bar graph that separates the data for males and females:
Grouped Bar Chart Output
Similarly, if you assign the SEX column to Stacking column and use frequency for Bar values, you can create a bar chart with males and females distinguished in the same bar for each age:
Stacked Bar Chart Output
You can also combine stacking and grouping to create grouped stacked bar charts.
By selecting Horizontal on the Bar Charts window, you can create bar charts with the bars running horizontally rather than vertically. Grouping and stacking options are also available for horizontal bar charts. Instead of being able to display a particular statistic for each bar (as in the vertical bar chart example earlier in this section), you can select Display statistics on the General Options window (found on the Additional Options window), which causes statistics to be displayed to the right of the bar chart.
Horizontal Bar Chart Output
By choosing items from the Additional Options menu, you can add a reference line to your bar chart; change the color, size, and font of the label text; change the appearance of the axes; and change the appearance of the legend.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.