Previous Page | Next Page

The CHART Procedure

Overview: CHART Procedure


What Does the CHART Procedure Do?

The CHART procedure produces vertical and horizontal bar charts, block charts, pie charts, and star charts. These types of charts graphically display values of a variable or a statistic associated with those values. The charted variable can be numeric or character.

PROC CHART is a useful tool that lets you visualize data quickly, but if you need to produce presentation-quality graphics that include color and various fonts, then use SAS/GRAPH software. The GCHART procedure in SAS/GRAPH software produces the same types of charts as PROC CHART does. In addition, PROC GCHART can produce donut charts.


What Types of Charts Can PROC CHART Create?


Bar Charts

Horizontal and vertical bar charts display the magnitude of data with bars, each of which represents a category of data. The length or height of the bars represents the value of the chart statistic for each category.

The following output shows a vertical bar chart that displays the number of responses for the five categories from the survey data. The following statements produce the output:

options nodate pageno=1 linesize=80 
        pagesize=30;

proc chart data=survey;
   vbar response / sumvar=count 
        midpoints='Always' 'Usually' 
           'Sometimes' 'Rarely' 'Never';
run;

Vertical Bar Chart

                                 The SAS System                                1

    Count Sum

    200 +                   *****
        |                   *****
        |                   *****
        |                   *****
        |                   *****
    150 +                   *****
        |                   *****
        |                   *****
        |                   *****       *****
        |       *****       *****       *****
    100 +       *****       *****       *****       *****
        |       *****       *****       *****       *****
        |       *****       *****       *****       *****
        |       *****       *****       *****       *****
        |       *****       *****       *****       *****
     50 +       *****       *****       *****       *****
        |       *****       *****       *****       *****       *****
        |       *****       *****       *****       *****       *****
        |       *****       *****       *****       *****       *****
        |       *****       *****       *****       *****       *****
        --------------------------------------------------------------------
               Always      Usually    Sometimes    Rarely       Never

                                      Response

The following output shows the same data presented in a horizontal bar chart. The two types of bar charts have essentially the same characteristics, except that horizontal bar charts by default display a table of statistic values to the right of the bars. The following statements produce the output:

options nodate pageno=1 linesize=80 
        pagesize=60;

proc chart data=survey;
   hbar response / sumvar=count
        midpoints='Always' 'Usually' 
           'Sometimes' 'Rarely' 'Never';
run;

Horizontal Bar Chart

                                 The SAS System                                1

       Response                                                    Count
                                                                     Sum
                   |
       Always      |*********************                       106.0000
                   |
       Usually     |****************************************    202.0000
                   |
       Sometimes   |************************                    119.0000
                   |
       Rarely      |*******************                          97.0000
                   |
       Never       |*********                                    44.0000
                   |
                   ----+---+---+---+---+---+---+---+---+---+
                       20  40  60  80 100 120 140 160 180 200

                                   Count Sum

Block Charts

Block charts display the relative magnitude of data by using blocks of varying height, each set in a square that represents a category of data. The following output shows the number of each survey response in the form of a block chart.

options nodate pageno=1 linesize=80 
        pagesize=30;

proc chart data=survey;
   block response / sumvar=count
         midpoints='Always' 'Usually' 
            'Sometimes' 'Rarely' 'Never';
run;

Block Chart

                                 The SAS System                                1

                            Sum of Count by Response

                         ___
                        /_ /|
                       |**| |
                       |**| |
                       |**| |          ___
           ___         |**| |         /_ /|          ___
          /_ /|        |**| |        |**| |         /_ /|
        -|**| |--------|**| |--------|**| |--------|**| |---------------------
       / |**| |      / |**| |      / |**| |      / |**| |      /   ___       /
      /  |**| |     /  |**| |     /  |**| |     /  |**| |     /   /_ /|     /
     /   |**| |    /   |**| |    /   |**| |    /   |**| |    /   |**| |    /
    /    |**|/    /    |**|/    /    |**|/    /    |**|/    /    |**|/    /
   /             /             /             /             /             /
  /      106    /      202    /      119    /       97    /       44    /
 /-------------/-------------/-------------/-------------/-------------/

    Always        Usually      Sometimes      Rarely         Never

                               Response

Pie Charts

Pie charts represent the relative contribution of parts to the whole by displaying data as wedge-shaped slices of a circle. Each slice represents a category of the data. The following output shows the survey results divided by response into five pie slices. The following statements produce the output:

options nodate pageno=1 linesize=80 
        pagesize=35;

proc chart data=survey;
   pie response / sumvar=count;
run;

Pie Chart

                                 The SAS System                                1

                            Sum of Count by Response


                                        Never
                                  ***********
                     Rarely   ****    .      ****
                            **        .      .   **
                          **          . 44   .     **
                         *            .7.75%.        *   Always
                       **      97     .    ..         **
                      **     17.08%   .   .            **
                      * ..            .   .     106     *
                     *     ..          . .    18.66%     *
                     *        .. .     ..                *
                     *            . .                    *
                     *                 +  . . .. . .. . .*
                     *     119                           *
                     *   20.95%     ..                   *
           Sometimes *             .                     *
                      *           .                     *
                      **         .        202          **
                        *      ..       35.56%        *
                         *    .                      *
                          ** .                     **
                            **                   **
                              ****           ****
                                  ***********    Usually


Star Charts

With PROC CHART, you can produce star charts that show group frequencies, totals, or mean values. A star chart is similar to a vertical bar chart, but the bars on a star chart radiate from a center point, like spokes in a wheel. Star charts are commonly used for cyclical data, such as measures taken every month or day or hour, or for data in which the categories have an inherent order ("always" meaning more frequent than "usually" which means more frequent than "sometimes"). The following output shows the survey data displayed in a star chart. The following statements produce the output:

options nodate pageno=1 linesize=80 
        pagesize=60;

proc chart data=survey;
   star response / sumvar=count;
run;

Star Chart

                                 The SAS System                                1

Center = 0                  Sum of Count by Response               Outside = 202


                                                 Never
                                 *************    44
                            *****             *****
                         ***                       ***
                      ***                             ***
                    **                                   **
                   *                                       *
         Rarely  **                                         **
           97   *                                             *
              **                                               **
              *                                                 *
             *                                                   *
            **                                                   **
            *               *......                               *
           **               . ..   ......*.                       **
           *               ..   ..      .. ...                     *
           *               .      ..    .     ....                 *
           *               .        .. ..         ...              *
           *               .          .+..............*            *  Always
           *              .         .. ..             .            *   106
           *              .      ...    .            .             *
           *              .     .        .           .             *
           **            ..  ...         .          ..            **
            *            . ..             .         .             *
            **           *.               ..        .            **
             *             ..              .       ..            *
              *              ..             .      .            *
               *               ..           .     ..           *
                *                ...        ..    .           *
      Sometimes  **                 ..       .    .         **
         119       *                  ...     .  ..        *
                    **                   .    .  .       **
                      ***                 ...  . .    ***
                         ***                 ....  ***
                            *****             *.***
                                 *************   Usually
                                                   202

Previous Page | Next Page | Top of Page