You are here: Commands > Extract

Extract

Menu: Found in the DATA menu

Use the Extract command to extract selected information from the current table. Extract offers three options:

Extract Record - outputs an exact copy of the selected records and maintains any established computed fields or relations. This includes any undefined portions of the record. The field definitions in the destination table layout are identical to those of the source table layout, including any computed field definitions and relations.
Extract Fields - outputs only selected fields from within the record. Any computed fields included in the field list are analyzed before extraction, and converted to data fields with their field type set to either Logical, Date, Character (ASCII or EBCDIC as required) or Arbutus (for numeric calculations). The resulting extracted table will be have a fixed record length. Analyzer automatically generates field definitions for the destination table layout.
Extract View - outputs the columns in the current View using the column headings as field names. Any computed fields included in the current View are analyzed before extraction, and converted to data fields with their field type set to either Logical, Date, Character (ASCII or EBCDIC as required) or Arbutus (for numeric calculations). If related fields are referenced in the currrent View, then the necessary relations are outputted as well. This allows you to extract only the data in the View (respecting any active filter). The resulting extracted table will be have a fixed record length. Analyzer automatically generates field definitions for the destination table layout.

Additionally, on the command line, Extract offers LIKE and EXCEPT options as part of the ALL command parameter. For a detailed discussion of using these options, see All.

There are various reasons to use Extract to create a subset of an original file (selected records or selected fields from selected records). For example, you can use Extract before sorting a table to reduce file size and processing time. You can also use Extract with filters to isolate unusual items or items of interest into a separate table for further analysis.

Note: Extracting records from a file that contains static and/or conditional static fields may yield unpredictable results. In this case, be sure to Extract only the fields you want, not the record.

Note: If you select all the fields from the Extract list box, the result may not be identical to extracting a record. Selecting fields for extraction ignores any undefined portions of the record. When you extract an entire record, you extract even those portions that are undefined.

Note: When processing Arbutus Server files that contain related fields, record output will be changed to All fields output if you specify the local option or keyword.

Note: When processing Arbutus zSeries Server based flat files or VSAM data, the Extract command supports Output User Exits. For more information on Output User Exits see Output User Exits.

Parameters

In addition to the command parameters described below, the Extract command has the following command parameters: Append, First, If, Next, Noformat, To and While. For a description of these parameters, see Command Parameters. For a description of supported field modifiers see Field Modifiers.

Fields

Allows you to specify the fields or expressions to extract. In the command dialog, choose the “Fields” radio button in the “Data to Extract” group box., then select the fields in the list box or click [Choose] to display the Selected Fields dialog. For more information see Selection/Edit Dialog Boxes.

Computed fields are converted to the appropriate field type in the created file: Arbutus, ASCII, Date or Logical.

Note: When extracting fields, ensure that the first field in the extract list is not called “No” as this will be interpreted by Analyzer as being the NOFORMAT parameter which will prevent Analyzer from creating a table layout for the extracted file. For more information see Noformat.

Record

Allows you to specify that the entire record (whether defined or not) including any computed field definitions will be extracted. In the command dialog, choose the “Record” radio button in the “Data to Extract” group box.

Note: When extracting records, the current View is created for the new table.

Presort

If Presort is specified, allows you to specify the field(s) to presort the data upon prior to exporting the selected data. In the command dialog, click the [More] button, then in the “Sort Options” click the “Presort Field(s)” radio button and then either select the fields in the list box (in sort order) or click [Choose] to display the Selected Fields dialog.

EOF

End of File processing causes the complete Extract command to be executed one more time after the end of the file has been reached. The End of File parameter is usually used in procedures when processing a file using the Group command and storing field values in variables. In the command dialog, click the [More] button, then click the “EOF (End of file processing)” checkbox.

This is normally used in situations where the information to be extracted cannot be determined until after a group of records has been processed.

Note: Whenever the End of File command parameter is used, it is mandatory that all information to be extracted is collected and stored in variables or is based solely on variables (see Variables). Fields and ad-hoc expressions are not supported when using the EOF parameter.

Local

This optional parameter applies only to files processed on an Arbutus Server. Local specifies that an output file is to be written to the Arbutus Client or local drive. When Local is specified, Extract writes output to the location of the current project file unless an alternate path is provided. In the command dialog, click the [More] button, then choose the “Local computer” radio button.

Server

This optional parameter enables files processed locally or on an Arbutus Server to be written to another Arbutus Server. When Server is specified, Extract writes output to the output prefix specified for the selected server profile unless an alternate path is provided. In the command dialog, click the [More] button, then choose the “Server” radio button and select the appropriate server profile.

Command Mode Syntax

EXTRACT {RECORD|<FIELDS> <field-list|ALL>} TO data-file-name

<LOCAL|SERVER profile-name>

<IF test> <WHILE test> <FIRST|NEXT range> <EOF>

<PRESORT field-list>

<NOFORMAT> <APPEND> <OPEN>¿

Note: When using the keyword SERVER, surround server profile names containing spaces with double quotes.

Where you have a long field list, a multi-line Extract can be constructed (in procedures only):

EXTRACT TO data-file-name

<IF|WHILE test><FIRST|NEXT n> <EOF>¿

field1 field2 field3¿

field4 field5 fieldn¿

<END|blank line>¿

Note: The END keyword or a blank line is required to terminate the field list.

Note: The command mode syntax for EXTRACT supports the use of the optional field modifiers AS and WIDTH after each field name. For more information see Field Modifiers.

Note: Whenever the End of File (EOF) command parameter is used, it is mandatory that all information to be extracted is collected and stored in variables or is based solely on variables (see Variables). Fields and ad-hoc expressions are not supported when using the EOF parameter.