Chapter 7: 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.

Output 7.1 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:

Output 7.1: Vertical Bar Chart
start example
 The SAS System                              1  Count Sum  200 +                   *****                         *****                         *****                         *****                         *****  150 +                   *****                         *****                         *****                         *****       *****             *****       *****       *****  100 +       *****       *****       *****       *****             *****       *****       *****       *****             *****       *****       *****       *****             *****       *****       *****       *****             *****       *****       *****       *****   50 +       *****       *****       *****       *****             *****       *****       *****       *****       *****             *****       *****       *****       *****       *****             *****       *****       *****       *****       *****             *****       *****       *****       *****       *****      --------------------------------------------------------------------            Always      Usually    Sometimes    Rarely       Never                                    Response 
end example
 
 options nodate pageno=1 linesize=80          pagesize=30;  proc chart data=survey;     vbar response / sumvar=count          midpoints='Always' 'Usually'             'Sometimes' 'Rarely' 'Never';  run; 

Output 7.2 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:

Output 7.2: Horizontal Bar Chart
start example
 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 
end example
 
 options nodate pageno=1 linesize=80          pagesize=60;  proc chart data=survey;     hbar response / sumvar=count          midpoints='Always' 'Usually'             'Sometimes' 'Rarely' 'Never';  run; 

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. Output 7.3 shows the number of each survey response in the form of a block chart.

Output 7.3: Block Chart
start example
 The SAS System                                 1                             Sum of Count by Response                          ___                         /_ /                        **                         **                         **           ___            ___         **          /_ /          ___           /_ /        **         **          /_ /         -** --------** --------** --------** ---------------------       / **       / **       / **       / **       /   ___       /       /  **      /  **      /  **      /  **      /   /_ /     /      /   **     /   **     /   **     /   **     /   **     /     /    **/    /    **/    /    **/    /    **/    /    **/    /    /             /             /             /             /             /   /      106    /      202    /      119    /       97    /       44    /  /-------------/-------------/-------------/-------------/-------------/     Always        Usually      Sometimes      Rarely         Never                                Response 
end example
 
 options nodate pageno=1 linesize=80          pagesize=30;  proc chart data=survey;     block response / sumvar=count           midpoints='Always' 'Usually'              'Sometimes' 'Rarely' 'Never';  run; 

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. Output 7.4 shows the survey results divided by response into five pie slices. The following statements produce the output:

Output 7.4: Pie Chart
start example
 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 
end example
 
 options nodate pageno=1 linesize=80          pagesize=35;  proc chart data=survey;     pie response / sumvar=count;  run; 

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 like these in which the categories have an inherent order ( always meaning more frequent than usually which means more frequent than sometimes ). Output 7.5 shows the survey data displayed in a star chart. The following statements produce the output:

Output 7.5: Star Chart
start example
 The SAS System                         1  Center = 0                    Sum of Count by Response        Outside = 202                                                     Never                                     *************    44                                *****             *****                             ***                       ***                          ***                             ***                        **                                   **                       *                                       *           Rarely    **                                         **             97     *                                             *                  **                                               **                  *                                                 *                 *                                                   *                **                                                   **                *                *......                              *               **                . ..   ......*.                      **               *                ..   ..      .. ...                    *               *               .       ..    .     ....                *               *               .         .. ..         ...             *               *               .           .+..............*           *   Always               *              .          .. ..             .           *    106               *              .      ...     .            .            *               *              .     .         .           .            *               **            ..  ...           .         ..           **                *            . ..               .        .            *                **           *.                  ..      .           **                 *             ..                 .     ..           *                  *              ..                .     .          *                   *               ..              .    ..         *                    *                ...           ..   .         *          Sometimes  **                 ..          .   .       **             119       *                  ...        . ..      *                        **                   .       . .     **                          ***                 ...   . .   ***                             ***                 ....  ***                                *****             *.***                                     *************   Usually                                                       202 
end example
 
 options nodate pageno=1 linesize=80          pagesize=60;  proc chart data=survey;     star response / sumvar=count;  run; 



Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net