REPORT command

Formats and generates a report based on the open Analytics table.

Syntax

REPORT <ON break_field <PAGE> <NODUPS> <WIDTH characters> <AS display_name>> <...n> FIELD other_fields <WIDTH characters> <AS display_name> <...n> <SUPPRESS> <NOZEROS> <LINE n other_fields> <PRESORT <sort_field>> <...n> <SUMMARIZED> <SKIP n> <EOF> <TO {SCREEN|PRINT|filename <HTML>}> <IF test> <WHILE test> <FIRST range|NEXT range> <HEADER header_text> <FOOTER footer_text> <APPEND> 

Parameters

Name Description

ON break_field PAGE NODUPS WIDTH characters AS display_name <...n>

optional

The character field or fields used to break the report into sections.

A new report section and subtotal is created each time the value in break_field changes. Breaking reports into sections can make them easier to scan.

  • break_field the field to use as a break field

    To run a report based on a view (DO REPORT), the break field must be the leftmost character field in the view.

  • PAGE inserts a page break when the break field value changes
  • NODUPS suppresses duplicate display values in the break field

    For example, if the customer name is listed for each invoice record, you can make the report more readable by listing only the first instance of each customer name.

  • WIDTH characters the output length of the field in characters
  • AS display_name the display name (alternate column title) for the field in the report

    Specify display_name as a quoted string. Use a semi-colon (;) between words if you want a line break in the column title. If you want the display name to be the same as the field name, or an existing display name in the source table, do not use AS.

Note

You must specify ON to use break_field , PAGE, NODUPS, or PRESORT.

FIELD other_fields WIDTH characters AS display_name <...n>

The fields to be included in the report.

  • WIDTH characters the output length of the field in characters
  • AS display_name the display name (alternate column title) for the field in the report

    Specify display_name as a quoted string. Use a semi-colon (;) between words if you want a line break in the column title. If you want the display name to be the same as the field name, or an existing display name in the source table, do not use AS.

The SUBTOTAL and ACCUMULATE keywords are synonyms for FIELD, and have been deprecated. All numeric fields are automatically subtotaled.

Note

Break fields are automatically included in the report and do not need to be specified as other_fields.

SUPPRESS

optional

Excludes blank detail lines from the report.

NOZEROS

optional

Substitutes blank values for zero values in the field.

For example, if a report includes a large number of zero values in a field, the report is easier to read if it only displays non-zero values.

LINE n other_fields

optional

Specifies the number of output lines in the column and the fields to appear on the line number n.

If no value is specified, the column defaults to a single line. The value of n must be between 2 and 60 inclusive.

Column headings on the report are determined solely by the fields on the first line. other_fields specifies appropriate fields or expressions for the report.

PRESORT sort_field <...n>

optional

  • Sorts break_field , if one or more break fields are specified.
  • Sorts sort_field, if one or more sort fields are specified.

PRESORT does not sort the fields listed as other_fields unless they are also listed as sort_field.

SUMMARIZED

optional

Produces a report with subtotals and totals only, and no detail lines.

Subtotals are generated for the unique break field values. If SUMMARIZED is not specified, Analytics produces a report that includes detail lines, as well as subtotals for each of the specified key break fields.

SKIP n

optional

Inserts blank lines between detail lines in the report.

n must be an integer specifying the number of lines to insert. For example, SKIP 1 produces a double-spaced report.

EOF

optional

Execute the command one more time after the end of the file has been reached.

This ensures that the final record in the table is processed when inside a GROUP command. Only use EOF if all fields are computed fields referring to earlier records.

TO SCREEN | PRINT| filename <HTML>

optional

The location to send the results of the command to:

  • SCREEN displays the results in the Analytics display area

    Tip

    You can click any linked result value in the display area to drill down to the associated record or records in the source table.

  • filename saves the results to a file

    Specify filename as a quoted string with the appropriate file extension. For example: TO "Output.TXT"

    By default, the file is saved to the folder containing the Analytics project.

    Use either an absolute or relative file path to save the file to a different, existing folder:

    • TO "C:\Output.TXT"
    • TO "Results\Output.TXT"
  • PRINT sends the results to the default printer

By default, reports output to a file are saved as ASCII text files. Specify HTML if you want to output the report as an HTML file (.htm).

If you omit TO, the report is output to screen.

IF test

optional

A conditional expression that must be true in order to process each record. The command is executed on only those records that satisfy the condition.

Note

The IF parameter is evaluated against only the records remaining in a table after any scope parameters have been applied (WHILE, FIRST, NEXT).

WHILE test

optional

A conditional expression that must be true in order to process each record. The command is executed until the condition evaluates as false, or the end of the table is reached.

Note

If you use WHILE in conjunction with FIRST or NEXT, record processing stops as soon as one limit is reached.

FIRST range | NEXT range

optional

The number of records to process:

  • FIRST start processing from the first record until the specified number of records is reached
  • NEXT start processing from the currently selected record until the specified number of records is reached

Use range to specify the number of records to process.

If you omit FIRST and NEXT, all records are processed by default.

HEADER header_text

optional

The text to insert at the top of each page of a report.

header_text must be specified as a quoted string. The value overrides the Analytics HEADER system variable.

FOOTER footer_text

optional

The text to insert at the bottom of each page of a report.

footer_text must be specified as a quoted string. The value overrides the Analytics FOOTER system variable.

APPEND

optional

Appends the command output to the end of an existing file instead of overwriting it.

Note

You must ensure that the structure of the command output and the existing file are identical:

  • the same fields
  • the same field order
  • matching fields are the same length
  • matching fields are the same data type

Analytics appends output to an existing file regardless of its structure. If the structure of the output and the existing file do not match, jumbled, missing, or inaccurate data can result.

Examples

Generating an HTML report

You generate a report from the Ar table and output the report to a formatted HTML file:

OPEN Ar
REPORT ON No FIELD Due Type Amount TO "C:\Reports\AR.htm" HTML