REPORT Procedure

Example 17: Using Multilabel Formats

Features:

PROC REPORT statement options: NOWD

COLUMN statement

DEFINE statement options:
FORMAT=
GROUP
MLF
MEAN
Other features:

FORMAT procedure option: multilabel

ODS HTML statement

Details

This example uses a multilabel format to create a report that does the following:
  • shows how to specify a multilabel format in the VALUE statement of PROC FORMAT
  • shows how to activate multilabel format processing using the MLF option with the DEFINE statement

Program

proc format;
  value agelfmt (multilabel)
     11='11'
     12='12'
     13='13'
     14='14'
     15='15'
     16='16'
     11-12='11 or 12'
     13-14='13 or 14'
     15-16='15 or 16'
     low-13='13 and below'
     14-high='14 and above' ;
run;
ods html file="example.html";
title "GROUP Variable with MLF Option";
proc report data=sashelp.class nowd;
   col age ('Mean' height weight);
   define age / group mlf format=agelfmt. 'Age Group'; 
   define height / mean format=6.2 'Height (in.)';
   define weight / mean format=6.2 'Weight (lbs.)';
run;
ods html close;

Program Description

Create the AGE1FMT. format.The FORMAT procedure creates a multilabel format for ages by using the MULTILABEL option. A multilabel format is one in which multiple labels can be assigned to the same value. Each value is represented in the table for each range in which it occurs.
proc format;
  value agelfmt (multilabel)
     11='11'
     12='12'
     13='13'
     14='14'
     15='15'
     16='16'
     11-12='11 or 12'
     13-14='13 or 14'
     15-16='15 or 16'
     low-13='13 and below'
     14-high='14 and above' ;
run;
Specify the ODS HTML output filename.
ods html file="example.html";
Specify a title.
title "GROUP Variable with MLF Option";
Specify the report options. The NOWD option runs the REPORT procedure without the REPORT window and sends its output to the open output destination.
proc report data=sashelp.class nowd;
Specify the report columns. The report contains a column for Age, Height, and Weight. The Mean of the Height and Weight are calculated.
   col age ('Mean' height weight);
Define the group variables. AGE is a group variable. The AGE variable uses the MLF option to activate multilabel format processing. FORMAT= specifies that the multilabel format, AGE1FMT. will be used. Each detail row of the report consolidates the information for all observations with the same values of the group variables. The mean is calculated for the HEIGHT and WEIGHT column values.
   define age / group mlf format=agelfmt. 'Age Group'; 
   define height / mean format=6.2 'Height (in.)';
   define weight / mean format=6.2 'Weight (lbs.)';
run;
Close the ODS HTML output.
ods html close;

Output

Multilabel Formatting