Example 3.7. Assigning Multiple Labels to Categories

Goal

Generate summary statistics for categories defined by the values of variables. Define multiple labels for some of the values, resulting in multiple representation of these values in the categories of the report.

Report

                                    Monthly
 Circulation Report

--------------------------------------------------
----------------------------------------
|                                 |               
    Items Circulated                   |
|                                
 |---------------
---------------------------------------|
|                                 |          |    
      |  Young   |          |          |
|                                 |  Adult   |
 Juvenile | People's |All Youth |  Total   |
|---------------------------------+----------+----
------+----------+----------+----------|
|Books           |Hardcover       |     15816|    
  4311|      1084|      5395|     21211|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |LargeType       |       131|    
     1|         2|         3|       134|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Paperback       |      4143|    
  3218|       712|      3930|      8073|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |     20090|    
  7530|      1798|      9328|     29418|
|----------------+----------------+----------+----
------+----------+----------+----------|
|Periodicals     |LargeType       |         9|    
     0|         0|         0|         9|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Magazines       |      4162|    
   433|       134|       567|      4729|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |      4171|    
   433|       134|       567|      4738|
|----------------+----------------+----------+----
------+----------+----------+----------|
|All Print       |Hardcover       |     15816|    
  4311|      1084|      5395|     21211|
|Material       
 |----------------+----------+----
------+----------+----------+----------|
|                |LargeType       |       140|    
     1|         2|         3|       143|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Magazines       |      4162|    
   433|       134|       567|      4729|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Paperback       |      4143|    
  3218|       712|      3930|      8073|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |     24261|    
  7963|      1932|      9895|     34156|
|----------------+----------------+----------+----
------+----------+----------+----------|
|Audio           |Audiocassettes  |      1569|    
   546|       388|       934|      2503|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |CompactDiscs    |      2018|    
     0|       370|       370|      2388|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |      3587|    
   546|       758|      1304|      4891|
|----------------+----------------+----------+----
------+----------+----------+----------|
|Talking Books   |Audiocassettes  |       483|    
   343|        24|       367|       850|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |CompactDiscs    |       184|    
    10|         4|        14|       198|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |       667|    
   353|        28|       381|      1048|
|----------------+----------------+----------+----
------+----------+----------+----------|
|Video           |DVD             |      4854|    
  1142|         0|      1142|      5996|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Videocassettes  |      6092|    
  3540|         0|      3540|      9632|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |     10946|    
  4682|         0|      4682|     15628|
|----------------+----------------+----------+----
------+----------+----------+----------|
|All Recordings  |Audiocassettes  |      2052|    
   889|       412|      1301|      3353|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |CompactDiscs    |      2202|    
    10|       374|       384|      2586|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |DVD             |      4854|    
  1142|         0|      1142|      5996|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Videocassettes  |      6092|    
  3540|         0|      3540|      9632|
|               
 |----------------+----------+----
------+----------+----------+----------|
|                |Total for Media |     15200|    
  5581|       786|      6367|     21567|
|---------------------------------+----------+----
------+----------+----------+----------|
|Total Items Circulated           |     39461|    
 13544|      2718|     16262|     55723|
--------------------------------------------------
----------------------------------------


Example Features

Data SetLIBRARIES
Featured StepsPROC FORMAT PROC TABULATE
Featured Step Statements and OptionsPROC FORMAT

VALUE statement: MULTILABEL option

PROC TABULATE

CLASS statement: MLF option

Use of Universal Classification Variable ALL

Formatting FeaturesMultiple labels for categories

Suppressing variable labels

PROC TABULATE TABLE statement: MISSTEXT= option; RTS= option when sending output to the LISTING destination
A Closer LookUnderstanding Multiple Labels

Example Overview

The value of a report’s presentation can be enhanced by grouping categories in various ways and including these additional combinations in the report.

This example report shows one month’s circulation totals for a library. It organizes the totals according to the values of three classification variables: media, audience, and type.

The report includes all unique combinations of the three class variables. Additionally, the report combines some of the categories into new categories, resulting in multiple representation of specific categories in the report.

For example, the new category “All Youth” sums the circulation totals for the “Juvenile” and “Young People’s” classifications.

Each observation in the LIBRARIES data set corresponds to the total number of items circulated for a specific combination of media, audience, type, category, and subcategory.

Program

Define the formats required for the report. Add the MULTILABEL option to formats that will be applied to variables that are to be multiply labeled. To control the ordering of the results, indent some of the labels a sufficient number of blanks.
proc format;
  value $aud (multilabel)
             'Adult'          ='   Adult'
             'Juvenile'       ='  Juvenile'
             "YoungPeople's"  =" Young People's"

Add an additional value label that combines these two values.
             'Juvenile',
             "YoungPeople's"  ='All Youth';
  value $med (multilabel)
             'Books'          ='      Books'
             'Periodicals'    ='    Periodicals'

Add an additional value label that combines these two values.
             'Books',
             'Periodicals'    =' All Print
              Material'
             'TalkingBooks'   =' Talking Books'
             'Audio'          =' Audio'
             'Video'          =' Video'

Add an additional value label that combines these three values.
             'TalkingBooks',
             'Audio','Video' ='All Recordings';
run;

proc tabulate data=libraries

Order the classification values by their ascending formatted values.
              order=formatted;

  title 'Monthly Circulation Report';

Specify the classification variables whose values are to be multiply labeled.
  class media audience / mlf;

Specify the classification variable whose values are not to be multiply labeled.
  class type;

  var items;

  table media=' '*(type=' '
        all='Total for Media')
        all='Total Items Circulated',
        all='Items Circulated'*
        (audience=' ' all='Total')*
        items=' '*sum=' '*f=10.

When sending output to the LISTING destination, specify the space allocated to row titles.
       / rts=35

Specify the text to write in cells with missing values.
         misstext='0';

  format media $med. audience $aud.;
run;


A Closer Look

Understanding Multiple Labels

The only procedures in SAS 9.1 that can process multiple labels are PROC MEANS, PROC SUMMARY, and PROC TABULATE. If you do not instruct SAS to use multiple labels within these three procedures, even if the format has been defined as multilabel, the feature is ignored. SAS also ignores any reference to a multilabel format in any procedure besides the three listed above.

It is important to understand what happens when you omit the MLF option in one of the three multilabel-enabled procedures, but you reference a multilabel format in the execution of the procedure. For example, if a value is multiply referenced in a PROC FORMAT VALUE statement, SAS uses only the value label associated with the first occurrence in the format definition. If the value is also included in a range and the range appears later in the format definition, you may see the range’s value label listed if your data set contains an observation with another value in that range. Note that if a value’s first occurrence is defined by a value label before the range that includes it is defined, that value is not represented in that range’s category.

Always use caution when interpreting reports that are based on multiple labels. The preceding example sums the analysis variable ITEMS. If you added up the cells in the rows labeled “Total for Media,” your sum would be greater than the value in the “Total Items Circulated” cell in the last row of the table. This is because of the multiple representation of values in the table.

When you write a VALUE statement in PROC FORMAT and do not include the MULTILABEL option, SAS looks for repeated ranges or overlapping values. If any are detected, the format is not created. Thus, if you submit the PROC FORMAT step in the preceding example with the MULTILABEL option omitted, SAS would not create the formats.

Where to Go from Here

PROC FORMAT reference, usage information, and additional examples. See “The FORMAT Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.

PROC TABULATE reference, usage information, and additional examples. See “The TABULATE Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.

Working with Formats. See “Formats and Informats” in the “SAS Language Elements” section of SAS 9.1 Language Reference: Concepts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.171.86