Manipulating Display Field Values in a Sort Group

You can use the WITHIN phrase to manipulate display field values as they are aggregated within a sort group. This technique can be used with a prefix operator to perform calculations on a specific aggregate field within a subset of all data.

The WITHIN phrase requires a BY phrase and/or an ACROSS phrase. A maximum of two WITHIN phrases can be used for each display field. If one WITHIN phrase is used, it must act on a BY phrase. If two WITHIN phrases are used, the first must act on a BY phrase and the second on an ACROSS phrase.

You can also use WITHIN TABLE, which allows you to return the original value within a request command. The WITHIN TABLE command can also be used when an ACROSS phrase is needed without a BY phrase. Otherwise, a single WITHIN phrase requires a BY phrase.

The basic format of the WITHIN command is:

field WITHIN {by_field|TABLE} [WITHIN across_field]

To display the gross salary and the percent of gross salary by job code within each department, issue the following request:

TABLE FILE EMPLOYEE
SUM ED_HRS PCT.ED_HRS WITHIN TABLE WITHIN DEPARTMENT
BY CURR_JOBCODE 
ACROSS DEPARTMENT
END

Run the request. The output is:

Note: Prefix operators, except for CNT. (I5) and PCT.CNT. (F6.2) use the format of the referenced field.

WebFOCUS

Feedback