Topics: |
How to: |
Reference: |
You can sort report information horizontally using the ACROSS phrase. This creates columns in your report. The total number of ACROSS columns is equal to the total number of ACROSS sort field values multiplied by the total number of display fields.
A request can include up to 128 sort phrases consisting of any combination of BY and ACROSS phrases.
The maximum number of display fields your report can contain is determined by a combination of factors. In general, if a horizontal (ACROSS) sort field contains many data values, you may exceed the allowed width for reports, or create a report that is difficult to read. For details, see Displaying Report Data.
You can produce column totals or summaries for ACROSS sort field values using ACROSS-TOTAL, SUBTOTAL, SUB-TOTAL, RECOMPUTE, and SUMMARIZE. For details, see Including Totals and Subtotals.
ACROSS sortfield
where:
Is the name of the sort field.
PRINT LAST_NAME ACROSS DEPARTMENT
prints MIS once, followed by six employee names.
The following illustrates how to show the total salary outlay for each department. This request is sorted horizontally with an ACROSS phrase.
TABLE FILE EMPLOYEE SUM CURR_SAL ACROSS DEPARTMENT END
The output is:
DEPARTMENT MIS PRODUCTION --------------------------------- $108,002.00 $114,282.00
Notice that the horizontal sort displays a column for each sort field (department).
How to: |
Using the SET ACRSVRBTITL command, you can control the display of an ACROSS column title in an ACROSS group. The behavior of the title is determined by the number of verb columns in the ACROSS group. The field count is affected by the following features, which add internal matrix columns to the report:
SET ACRSVRBTITL = {HIDEONE|ON|OFF} ON TABLE SET ACRSVRBTITL {HIDEONE|ON|OFF}
where:
Suppresses the title when there is only one display field, or there is only one display field and the request contains one or more of the features that add internal matrix columns to the report. This value is the default.
Always displays the title even if there is only one display field.
Suppresses the title when there is only one display field. Displays the title when there is only one display field and the request contains one or more of the features that add internal matrix columns to the report. This is legacy behavior.
The following request against the GGSALES data source has a display field in the heading:
SET ACRSVRBTITL=HIDEONE TABLE FILE GGSALES HEADING "Sales Report for <CATEGORY with ACRSVRBTITL=HIDEONE" " " SUM DOLLARS AS Sales BY CATEGORY ACROSS REGION WHERE CATEGORY EQ 'Food' ON TABLE SET PAGE NOPAGE ON TABLE SET ACROSSTITLE SIDE ON TABLE SET ACROSSLINE SKIP ON TABLE SET STYLE * TYPE=REPORT, GRID=OFF, FONT='ARIAL', SIZE=9, SQUEEZE=ON,$ TYPE=TITLE,JUSTIFY=LEFT,BACKCOLOR=RGB(102 102 102),COLOR=RGB(255 255 255),STYLE=BOLD,$ TYPE=HEADING, SIZE=11, STYLE=BOLD,JUSTIFY=CENTER, $ TYPE=ACROSSTITLE,STYLE=BOLD,$ TYPE=ACROSSVALUE,BACKCOLOR=RGB(218 225 232),$ END
Using the default value for ACRSVRBTITL, HIDEONE, suppresses the ACROSS title Sales, even though the heading displays a field value that adds a report column to the internal matrix.
The report output is shown in the following image:
If you change the SUM command to the following:
SUM DOLLARS/D12CM
the field in the heading and the reformatted dollar sales values add report columns to the internal matrix, but the ACROSS title Sales is still suppressed.
The report output is shown in the following image:
Using the ACRSVRBTITL value ON, without reformatting the dollar sales column, does not suppress the ACROSS title Sales because the heading displays a field value that adds a report column to the internal matrix.
The report output is shown in the following image:
If you change the SUM command to the following:
SUM DOLLARS/D12CMC
the field in the heading and the reformatted dollar sales values add report columns to the internal matrix, so the ACROSS title Sales is not suppressed.
The report output is shown in the following image:
With the setting ACRSVRBTITL=OFF, the field in the heading adds a report column to the internal matrix, and the ACROSS title Sales is not suppressed.
The report output is shown in the following image:
If you change the SUM command to the following:
SUM DOLLARS/D12CM
the field in the heading and the reformatted dollar sales values add report columns to the internal matrix, and the ACROSS title Sales is not suppressed.
The report output is shown in the following image:
How to: |
Reference: |
In a report that uses the ACROSS sort phrase to sort values horizontally across the page, by default, two lines are generated on the report output for the ACROSS columns. The first line displays the name of the sort field (ACROSS title), and the second line displays the values for that sort field (ACROSS value). The ACROSS field name is left justified above the first ACROSS value.
If you want to display both the ACROSS title and the ACROSS values on one line in the PDF, HTML, EXL2K report output, you can issue the SET ACROSSTITLE = SIDE command. This command places ACROSS titles to the left of the ACROSS values. By default, the titles are right justified in the space above the BY field titles. You can change the justification of the ACROSS title by adding the JUSTIFY attribute to the StyleSheet declaration for the ACROSSTITLE component. If there are no BY fields, the heading line that is created by default to display the ACROSS title will not be generated.
This feature is designed for use in requests that have both ACROSS fields and BY fields. For requests with ACROSS fields but no BY fields, the set command is ignored, and the ACROSS titles are not moved.
Note that for certain output formats, you can control whether column titles are underlined using the SET TITLELINE command. SET ACROSSLINE is a synonym for SET TITLELINE. For information, see .
SET ACROSSTITLE = {ABOVE|SIDE}
where:
Displays ACROSS titles above their ACROSS values. ABOVE is the default value.
Displays ACROSS titles to the left of their ACROSS values, above the BY columns.
The following example against the GGSALES data source has two ACROSS sort fields, CATEGORY and PRODUCT. SET ACROSSTITLE=SIDE moves the ACROSS title to the left of the ACROSS values. With BYPANEL=ON the ACROSS titles are repeated in the same location on each subsequent panel.
SET ACROSSTITLE=SIDE SET BYPANEL=ON TABLE FILE GGSALES SUM DOLLARS/I8M AS '' BY REGION BY ST BY CITY ACROSS CATEGORY ACROSS PRODUCT WHERE PRODUCT NE 'Capuccino'; ON TABLE SET PAGE-NUM ON ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT PDF ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * UNITS=IN, SQUEEZE=ON, ORIENTATION=PORTRAIT, $ TYPE=REPORT, FONT='ARIAL', SIZE=10, BORDER=LIGHT, $ TYPE=ACROSSVALUE, WRAP=ON, $ ENDSTYLE END
The ACROSS title Category displays to the left of the ACROSS values Coffee, Food, and Gifts. The ACROSS title Product displays to the left of the ACROSS values Espresso, Latte, Biscotti, and so on. The ACROSS titles are right-justified above the space occupied by the BY field names Region, State, and City. Notice that the ACROSS value Croissant wraps onto a second line, and the ACROSS title is aligned with the top line. The following shows panel 1:
The following shows panel 2:
The following example against the GGSALES data source has two BY fields and two ACROSS fields. This example does not set borders on and does not enable wrapping of the ACROSS values. SET ACROSSTITLE=SIDE moves the ACROSS title to the left of the ACROSS values. The SET BYPANEL=1 command repeats only the first BY field on the second panel. To prevent the ACROSS titles from being truncated to fit above the BY field on the second panel, the first BY field has an AS name that is longer than the default name:
SET ACROSSTITLE=SIDE SET BYPANEL=1 TABLE FILE GGSALES SUM DOLLARS/I8M AS '' BY ST AS 'State Code' BY CITY ACROSS CATEGORY AS 'Categories' ACROSS PRODUCT AS 'Products' WHERE PRODUCT NE 'Capuccino'; ON TABLE SET PAGE-NUM ON ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT PDF ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * UNITS=IN, SQUEEZE=ON, ORIENTATION=PORTRAIT, $ TYPE=REPORT, FONT='ARIAL', SIZE=10, $ ENDSTYLE END
The first panel follows:
Because of the SET BYPANEL=1 command, the space available above the BY fields on the second panel is smaller than the space on the initial panel. The AS name State Code adds space for the ACROSS titles, so the titles are not truncated on the second panel:
The following request against the GGSALES data source places the ACROSS titles next to the ACROSS values and sets matching styling of font color and backcolor for the ACROSSTITLES, ACROSSVALUES, and column titles to white text on grey background color.
SET ACROSSTITLE=SIDE TABLE FILE GGSALES SUM DOLLARS/I8M AS '' BY REGION BY ST BY CITY ACROSS CATEGORY ACROSS PRODUCT WHERE CATEGORY EQ 'Coffee' OR 'Food'; ON TABLE SET PAGE-NUM NOPAGE ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT HTML ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * SQUEEZE=ON,UNITS=IN,ORIENTATION=PORTRAIT,$ TYPE=REPORT,FONT='ARIAL',SIZE=10,BORDER=LIGHT,$ TYPE=ACROSSTITLE,COLOR=WHITE, BACKCOLOR=GREY,$ TYPE=ACROSSVALUE,COLOR=WHITE, BACKCOLOR=GREY,$ TYPE=TITLE,COLOR=WHITE, BACKCOLOR=GREY,$ ENDSTYLE END
The output has a grey background color and white text for the ACROSS titles, ACROSS values, and column titles.
You can sort a report using more than one sort field. When several sort fields are used, the ACROSS phrase order determines the sorting order. The first ACROSS phrase sets the first sort break, the second ACROSS phrase sets the second sort break, and so on. Each successive sort is nested within the previous one.
The following request sorts the sum of current salaries, first by department and then by job code.
TABLE FILE EMPLOYEE SUM CURR_SAL ACROSS DEPARTMENT ACROSS CURR_JOBCODE WHERE CURR_SAL GT 21500 END
The output is:
DEPARTMENT MIS PRODUCTION CURR_JOBCODE A17 B04 A15 A17 ------------------------------------------------------------------------ $27,062.00 $21,780.00 $26,862.00 $29,700.00
How to: |
Reference: |
The PRINT command generates a report that has a single line for each record retrieved from the data source after screening out those that fail IF or WHERE tests. When PRINT is used in conjunction with an ACROSS phrase, many of the generated columns may be empty. Those columns display the missing data symbol.
To avoid printing such a sparse report, you can use the SET ACROSSPRT command to compress the lines in the report. The number of lines is reduced within each sort group by swapping non-missing values from lower lines with missing values from higher lines, and then eliminating any lines whose columns all have missing values.
Because data may be moved to different report lines, row-based calculations such as ROW-TOTAL and ACROSS-TOTAL in a compressed report are different from those in a non-compressed report. Column calculations are not affected by compressing the report lines.
SET ACROSSPRT = {NORMAL|COMPRESS}
ON TABLE SET ACROSSPRT{NORMAL|COMPRESS}
where:
Does not compress report lines. NORMAL is the default value.
Compresses report lines by promoting data values up to replace missing values within a sort group.
The following request against the GGSALES data source prints unit sales by product across region:
TABLE FILE GGSALES
PRINT UNITS/I5
BY PRODUCT
ACROSS REGION
WHERE DATE FROM '19971201' TO '19971231';
WHERE PRODUCT EQ 'Capuccino' OR 'Espresso';
ON TABLE SET ACROSSPRT NORMAL
ON TABLE SET PAGE NOPAGE
END
Each line of the report represents one sale in one region, so at most one column in each row has a non-missing value when ACROSSPRT is set to NORMAL.
Region Midwest Northeast Southeast West Product Unit Sales Unit Sales Unit Sales Unit Sales ----------------------------------------------------------------- Capuccino . 936 . . . 116 . . . 136 . . . . 1616 . . . 1118 . . . 774 . . . . 1696 . . . 1519 . . . 836 Espresso 1333 . . . 280 . . . 139 . . . . 1363 . . . 634 . . . 406 . . . . 1028 . . . 1014 . . . 885 . . . . 1782 . . . 1399 . . . 551
Setting ACROSSPRT to COMPRESS promotes non-missing values up to replace missing values within the same BY group and then eliminates lines consisting of all missing values.
TABLE FILE GGSALES
PRINT UNITS/I5
BY PRODUCT
ACROSS REGION
WHERE DATE FROM '19971201' TO '19971231';
WHERE PRODUCT EQ 'Capuccino' OR 'Espresso';
ON TABLE SET ACROSSPRT COMPRESS
ON TABLE SET PAGE NOPAGE
END
The output is:
Region Midwest Northeast Southeast West Product Unit Sales Unit Sales Unit Sales Unit Sales ---------------------------------------------------------------- Capuccino . 936 1616 1696 . 116 1118 1519 . 136 774 836 Espresso 1333 1363 1028 1782 280 634 1014 1399 139 406 885 551
WebFOCUS | |
Feedback |