Creating Labels to Identify Data

In this section:

Labels enable you to provide meaningful and distinct names for the following report elements that are otherwise identified by generic labels:

Creating a Label for a Row or Column Total

How to:

A label for a row or column total identifies the sum of values for two or more fields. A label draws attention to the total. It is particularly important that you create a label for a row or column total if you have both in one report.

For related information, see Including Totals and Subtotals.

Syntax: How to Create a Label for a Row or Column Total

fieldname [AND] ROW-TOTAL[/justification][/format] [AS 'label'] 
fieldname [AND] COLUMN-TOTAL[/justification] [AS 'label']

or

fieldname [AND] COLUMN-TOTAL[/justification] [AS 'label']

where:

fieldname
Is a field named in a display command.
justification
Is the alignment of the label. Valid values are:

L which left justifies the label.

R which right justifies the label.

C which centers the label.

For related information, see Justifying a Label for a Row or Column Total.

format
Is the format of the row or column total. When fields with the same format are summed, the format of the total is the same as the format of the fields. When fields with different formats are summed, the default D12.2 is used for either the row or column total.
label
Is the customized row or column total label. The default label is TOTAL.

You can also specify a row or column total with the ON TABLE phrase. With this syntax, you cannot include field names with ROW-TOTAL. Field names are optional with COLUMN-TOTAL.

ON TABLE ROW-TOTAL[/justification][/format] [AS 'label']
ON TABLE COLUMN-TOTAL[/justification] [AS 'label']
 [fieldname fieldname fieldname]

If a request queries a field created with COMPUTE, the value of that field is included in a row or column total. Keep that in mind when customizing a label that identifies the total.

Example: Creating a Label for a Row and Column Total

This request creates the label Total Population by State for the row total, and the label Total Population by Gender for the column total. The format D12 for ROW-TOTAL displays that data with commas.

TABLE FILE GGDEMOG
PRINT MALEPOP98 FEMPOP98 
ROW-TOTAL/D12 AS 'Total Population by State' 
BY ST
WHERE (ST EQ 'WY' OR 'MT') 
ON TABLE COLUMN-TOTAL AS 'Total Population by Gender' 
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

The output is:

Example: Creating a Row Total Label With ACROSS

This request adds the populations of two states, sorts the information using the ACROSS phrase, and labels the row totals as Total by Gender. There are two row totals within the Total by Gender column, Male Population and Female Population.

TABLE FILE GGDEMOG
SUM MALEPOP98/D12 FEMPOP98/D12 
ROW-TOTAL AS 'Total by Gender'  
ACROSS ST
WHERE ST EQ 'WY' OR 'MT';
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

The output is:

Creating a Label for a Subtotal and a Grand Total

How to:

Frequently, a report contains detailed information for a sort group, and it is useful to provide a subtotal for such a group, and a grand total for all groups at the end of the report.

For related information see Including Totals and Subtotals.

Syntax: How to Create a Label for a Subtotal or a Grand Total

{BY|ON} fieldname {SUB-TOTAL|SUBTOTAL|COLUMN-TOTAL} [MULTILINES]
        [field1 [AND] field2...] [AS 'label'] [WHEN expression;]

where:

fieldname
Is a sort field named on a BY or ON phrase.
MULTILINES
Suppresses a subtotal when there is only one value at a sort break. After it is specified, MULTILINES suppresses the subtotal for every sort break with only one detail line. MULTI-LINES is a synonym for MULTILINES.
field1 field2
Are specific fields that will be subtotaled. A specified field overrides the default, which includes all numeric display fields.
AS 'label'
Is the customized label for the subtotal. You cannot change the default label for a higher level sort field if using SUB-TOTAL.
WHEN expression
Specifies a conditional subtotal as determined by a logical expression. For details, see Using Expressions.

Example: Creating a Label for a Subtotal and a Grand Total

This request creates a customized label for the subtotal, which is the total dollar amount deducted from employee paychecks for city taxes per department; and the grand total which is the total dollar amount for both departments.

TABLE FILE EMPLOYEE
SUM DED_AMT BY DED_CODE BY DEPARTMENT
BY BANK_ACCT
WHERE DED_CODE EQ 'CITY'
WHERE BANK_ACCT NE 0 
ON DEPARTMENT SUBTOTAL AS 'Total City Deduction for'
ON TABLE COLUMN-TOTAL AS '**GRAND TOTAL**' 
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

In the output, the department values MIS and PRODUCTION are included by default in the customized subtotal label.

Example: Creating a Label for the Subtotal of a Specific Field

This request creates a customized label, Order Total, for the subtotal for LINEPRICE. It uses the default label TOTAL for the grand total.

TABLE FILE CENTORD
PRINT PNUM QUANTITY LINEPRICE 
BY ORDER_NUM SUBTOTAL LINEPRICE AS 'Order Total' 
WHERE ORDER_NUM EQ '28003' OR '28004';
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

The output is:

Syntax: How to Create a Label for the Subtotal of a Calculated Value

{BY|ON} fieldname {SUMMARIZE|RECOMPUTE} [MULTILINES]
        [field1 [AND] field2...] [AS 'label'] [WHEN expression;]
ON TABLE {SUMMARIZE|RECOMPUTE}

where:

fieldname
Is a sort field named on a BY or ON phrase.
MULTILINES
Suppresses a subtotal when there is only one value at a sort break. After it is specified, MULTILINES suppresses the subtotal for every sort break with only one detail line. MULTI-LINES is a synonym for MULTILINES.
field1 field2
Are specific fields that will be subtotaled. Specified fields override the default, which includes all numeric display fields.
AS 'label'
Is the customized label for the subtotal. You cannot change the default label for a higher level sort field if using SUMMARIZE.
WHEN expression
Specifies a conditional subtotal as determined by a logical expression. For details, see Using Expressions.

You can also generate a subtotal with the ON TABLE phrase:

ON TABLE {SUMMARIZE|RECOMPUTE}

Example: Creating a Label for the Subtotal of a Calculated Value

This request creates a customized label for the subtotal, including the calculation for the field DG_RATIO, created with COMPUTE.

TABLE FILE EMPLOYEE
SUM GROSS DED_AMT AND COMPUTE
DG_RATIO/F4.2 = DED_AMT / GROSS;
BY DEPARTMENT BY BANK_ACCT
WHERE BANK_ACCT NE 0 
ON DEPARTMENT SUMMARIZE AS 'SUBTOTAL FOR ' 
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $
ENDSTYLE
END

In the output, the department values MIS and PRODUCTION are included by default in the customized subtotal label. The default grand total label is TOTAL.

Creating a Label for a Row in a Financial Report

Financial Modeling Language (FML) meets the special needs associated with creating, calculating, and presenting financially oriented data. FML reports are structured on a row-by-row basis. This organization gives you greater control over the data incorporated into a report and over its presentation.

You identify rows by labels that you can customize for accurate data identification and format to enhance the visual appearance and clarity of the data.

For details on FML reports, see Creating Financial Reports With Financial Modeling Language (FML).