SEQUENCE command

Concept Information

Testing sequential order

Determines if one or more fields in an Analytics table are in sequential order, and identifies out-of-sequence items.

Syntax

SEQUENCE <ON> {<FIELDS> key_field <D> <...n>|<FIELDS> ALL <EXCLUDE field_name <...n>>} <UNFORMATTED> <ERRORLIMIT n> <IF test> <WHILE test> <FIRST range|NEXT range> <TO {SCREEN|filename|PRINT}> <APPEND> <HEADER header_text> <FOOTER footer_text> <PRESORT> <ISOLOCALE locale_code>

Parameters

Name Description
ON FIELDS key_field D <...n> | FIELDS ALL

One or more character, numeric, or datetime fields to test for sequential order.

  • FIELDS key_field test the specified field or fields

    Multiple fields must be separated by spaces, and can be different data types.

    If you test by more than one field, fields are tested in the order that you list them.

    Include D to test key field values in descending order. The default test order is ascending.

  • FIELDS ALL test all fields in the table

    If you test by all fields, fields are tested in the order that they appear in the table layout.

    Testing key field values in ascending order is the only option for FIELDS ALL.

Note

When you test by more than one field, you are testing for a nested sequential order in the source table. Valid use of SEQUENCE requires that you specify test fields in the same order as the existing nested sequential order in the source table. Multiple test fields are tested as a nested group. They are not tested independently of one another.

EXCLUDE field_name

optional

Only valid when testing for sequential order using FIELDS ALL.

The field or fields to exclude from the command. EXCLUDE allows you to fine-tune FIELDS ALL, by excluding the specified fields.

EXCLUDE must immediately follow FIELDS ALL. For example:

FIELDS ALL EXCLUDE field_1 field_2 

UNFORMATTED

optional

Suppresses page headings and page breaks when the results are output to a file.

ERRORLIMIT n

optional

The number of errors allowed before the command is terminated. The default value is 10.

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.

TO SCREEN | filename | PRINT

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

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.

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.

PRESORT

optional

Sorts the table on the key field before executing the command.

Note

You cannot use PRESORT inside the GROUP command.

ISOLOCALE locale_code

optional

Note

Applicable in the Unicode edition of Analytics only.

The system locale in the format language_country. For example, to use Canadian French, enter fr_ca.

Use the following codes:

  • language ISO 639 standard language code
  • country ISO 3166 standard country code

    If you do not specify a country code, the default country for the language is used.

If you do not use ISOLOCALE, the default system locale is used.

Analytics output variables

Name Contains
WRITEn

The total number of sequence errors identified by the command.

Examples

Testing for out-of-sequence employee IDs

You write any sequence errors identified in the EmployeeID field to a text file:

SEQUENCE ON EmployeeID ERRORLIMIT 10 TO "SequenceErrors.txt"

Remarks

For more information about how this command works, see Testing sequential order.

Using SEQUENCE inside a GROUP

If you use SEQUENCE inside a GROUP command, the command executes to avoid interfering with the processing of the group, but no further data sequence errors are reported.