CLASSIFY command

Used to group records based on unique values in a character field. Counts the number of records in each group, and also subtotals specified numeric fields for each group.

Syntax

CLASSIFY <ON> character_field <SUBTOTAL numeric_field <...n>> <INTERVALS number>
<SUPPRESS> <TO SCREEN|table_name|GRAPH|PRINT> <IF test> <WHILE test>
<FIRST|NEXT range> <HEADER header_text> <FOOTER footer_text>
<KEY break_field> <OPEN> <APPEND> <LOCAL> <STATISTICS>

Parameters

ON character_field

Specifies the character field or expression to be classified. The ON parameter can be omitted.

SUBTOTAL numeric_field <...n>

Optional. Specifies one or more numeric fields or expressions to subtotal for each group. Multiple fields must be separated by spaces. Specify ALL to subtotal all the numeric fields in the table.

INTERVALS number

Optional. Specifies the maximum number of groups in the output result. If the number of unique values in the field being classified exceeds the specified maximum, unique values are used starting from the top of the column. Unique values exceeding the maximum are grouped together in a group called “OTHER”.

If the INTERVALS parameter is omitted, a group is created for each unique value in the field being classified. This parameter is not available in the ACL user interface and can only be used as part of ACLScript syntax in a script or the command line.

SUPPRESS

Optional. Specifies that unique values exceeding the maximum specified by the INTERVALS parameter are excluded from the command output. The SUPPRESS parameter has no effect if the INTERVALS parameter is not also used. The SUPPRESS parameter is not available in the ACL user interface and can only be used as part of ACLScript syntax in a script or the command line.

TO SCREEN | table_name | GRAPH | PRINT
  • Specify TO SCREEN to display the results in the ACL display area. This is the default output if the TO parameter is not specified.

  • Specify TO table_name to save the results to an ACL table. You must specify the table_name value as a quoted string with a .FIL file extension to create an ACL table.

    For example: TO "Output.FIL"

    You can also specify an absolute or relative file path to save the .FIL file to an existing folder.

    For example: TO "C:\Output.FIL" or TO "Results\Output.FIL"

  • Specify TO PRINT to send the results to the default printer.

  • Specify TO GRAPH to display the results in a graph in the ACL display area.

IF test

Optional. Specifies a condition that must be met. The command is executed on only those records that meet the condition.

WHILE test

Optional. Specifies that the command is executed only while a condition is true. The command processing terminates as soon as the specified condition evaluates as false, or the end of the table is reached.

FIRST | NEXT range

Optional. Specify FIRST to start processing at the first record or NEXT to start processing at the currently selected record. Use the range value to specify the number of records to process.

HEADER header_text

Optional. Specifies the text to insert at the top of each page of a report. The header_text value must be specified as a quoted string. The value overrides any value set for the ACL HEADER system variable.

FOOTER footer_text

Optional. Specifies the text to insert at the bottom of each page of a report. The footer_text value must be specified as a quoted string. The value overrides any value set for the ACL FOOTER system variable.

KEY break_field

Optional. Specifies that a subtotal is calculated each time the value of the specified field or expression changes. You can specify only one field, but you can create and specify an expression that contains more than one field. The break_field must be a character field or expression.

OPEN

Optional. Specifies that the table created by the command is opened after the command executes. This parameter is only valid if the command creates an output table.

APPEND

Optional. Specifies that command output is appended to the end of an existing file instead of overwriting it. When using this parameter, you must ensure that the structure of the command output and the existing file is identical, if maintaining a consistent file structure is important (for example, when you are appending data to an existing ACL table), because ACL appends output to an existing file regardless of its structure.

LOCAL

Optional. Specifies that the output file is saved in the same location as the ACL project. This parameter only applies when the command is run on an ACL Server table and the output file is an ACL table.

STATISTICS

Optional. Specifies that average, minimum, and maximum values are calculated for all SUBTOTAL fields. If you specify the STATISTICS parameter you must also specify the SUBTOTAL parameter with at least one field.

Remarks

The CLASSIFY command groups records that have the same value in a character field. The output results contain a single record for each group, with a count of the number of records in the source table that belong to the group.

The CLASSIFY command can process either sorted or unsorted data. Output results are automatically sorted in ascending order.

You can classify a numeric field by using the STRING( ) function to create an expression that converts the numeric data to character data. For example:

CLASSIFY ON STRING(Unit_Cost, 22) TO "Identical_unit_costs.fil"

creates output results that group and count identical unit costs. For more information, see STRING( ) function.

The CLASSIFY command supports a maximum key field length of 64 characters. If you want to classify a table using a key field longer than 64 characters, you can use the SUMMARIZE command, which does not have a length restriction, instead of CLASSIFY. You can also use either of the following methods:

If you use the optional STATISTICS parameter, average, minimum, and maximum values are calculated for each subtotaled numeric field. If you output the results to an ACL table, the fields generated by the SUBTOTAL and STATISTICS parameters use the following naming conventions:

Table 1. Naming conventions for subtotal and statistics fields

Subtotal field

Average field

Minimum field

Maximum field

field name in output table

subtotaled field name in source table

a_subtotaled field name in source table

m_subtotaled field name in source table

x_subtotaled field name in source table

alternate column title in output table

(the column display name in the view)

Total + subtotaled alternate column title in source table

Average + subtotaled alternate column title in source table

Minimum + subtotaled alternate column title in source table

Maximum + subtotaled alternate column title in source table

Examples

a. Total transaction amount per customer

The following example classifies an accounts receivable table on the Customer Number field, and subtotals the Transaction Amount field. The output results are grouped by customer, and include the total transaction amount for each customer.

OPEN Ar
CLASSIFY ON Customer_Number SUBTOTAL Trans_Amount TO "Customer_total.FIL"

b. Total, average, minimum, and maximum transaction amounts per customer

If you add the STATISTICS parameter, in addition to the subtotaled transaction amount for each customer, you also calculate the average, minimum, and maximum transaction amounts for each customer.

OPEN Ar
CLASSIFY ON Customer_Number SUBTOTAL Trans_Amount TO "Customer_stats.FIL"
STATISTICS


(C) 2015 ACL Services Ltd. All Rights Reserved.