Appending output results to an existing table

Any Analytics operation that allows you to output results to a new Analytics table or a text file also allows you to append the results to an existing Analytics table or a text file. Appending attaches the records in the output results as a group to the end of the existing table or file – that is, after the last record in the existing table or file.

How sorting works

Any existing sort orders in the output results and the target table or file are separately maintained in the respective record sets in the resulting combined data. If required, you can subsequently sort the combined table to create a single sort order throughout all records.

Identical data structure required

For appending to an Analytics table to be successful, the records in the output results and the target table must be exactly identical in structure. The following structural characteristics must all be identical:

  • the selection of data elements
  • the number and order of fields
  • the data type and length of corresponding fields
  • the format of corresponding date and datetime fields
  • the length of records

If even one characteristic of the record structures is not identical, jumbled data can result. Identical structure is not a requirement when appending to text files.

For more information about record structure, see Data structure and data format requirements.

For information about using the DISPLAY command to compare the data structures of two tables, see Comparing data structures.

The Append To Existing File option

Selecting the Append To Existing File option prior to performing an Analytics operation forces the append of the output results to the target table. The append takes place regardless of whether the data structures are identical. Select this option only if you are certain the data structures are identical.

The Append button

A safer approach when appending to an Analytics table is to leave Append To Existing File deselected. If the option is deselected, upon processing of the active table Analytics compares the record lengths of the output results and the target table. If the record lengths are identical, the Append button appears as an option in the overwrite prompt.

Limits of the Append button

Even if the Append button appears, the two data structures may not be identical. For example, the output results and the target table could each have a record length of 100 characters, but the fields could be in a different order, there could be a different number of fields, or the data type of aligned fields (same start position and field length) could be different.

When the Append button does not appear

If the Append button does not appear, the record lengths are not identical, which means one or more aspects of the data structures are not identical, and may require manual harmonizing before you proceed. This automated check occurs only if the target table is in the open Analytics project.

Warn Before Overwriting Files option

In order for the overwrite prompt to appear, Warn Before Overwriting Files must be selected in the Options dialog box (the default setting). If Warn Before Overwriting Files is deselected, the overwrite prompt does not appear, the automated check of record lengths is not performed, and output results always overwrite target tables rather than being appended to them — unless you select Append To Existing File.