G Correlative

Group Extraction. The G correlative extracts one or more fields from a delimited character string.

Format

G [skip] delimiter #fields

Parameter(s)

skip

Specifies the number of fields to skip. If m is not specified, zero is assumed and no fields are skipped.

delimiter

Field separator. This delimiter can be any single nonnumeric character except a minus sign () or a system delimiter (SM, AM, VM, SVM, or SB).

#fields

A decimal number indicating the number of contiguous delimited fields to extract. If n = 0, a null value is returned.

Using the G Correlative

Attribute 2 in a personnel database contains a department ID and a job ID separated by a slash (/). The stored data has the format:

30/110

This Attribute Synonym Definition item could be used to extract just the department ID:

   DEPT

001 S

002 2

003 Department

004

005

006

007

008 G / 1

009 L

010 3

The G correlative in the example extracts only one field, the first one. Alternatively, the correlative G1/1 would skip the first field and extract only the second one.

The G correlative can also be used to extract data elements that are separated by blanks. For instance, if an attribute contains a person’s first and last names, you can extract either the first or the last name with the G correlative.

The examples listed in the table below illustrate how the G correlative works. The stored data for all these examples is 10/20/30/40:

If the G Correlative is…

Then Data Extracted is…

G/1

10

G/2

10/20

G1/1

20

G1/2

20/30

G2/1

30

G4/1

<null>

See Also

Correlatives and Conversions Reference