A.
The facility for grouping elementary items under a group item with the REPORT procedure is very useful and adds much to the readability of reports. However, if an entire group will not fit on the current page, PROC
REPORT outputs as many elementary items as it can and then continues the group on the next page. This may be undesirable, depending on the content of the report and its intended audience. It may be preferrable to have a group that would normally be split on two pages start on a newpage.
This can be accomplished by creating a page control variable in the data set prior to entering PROC
REPORT and then using this variable to control when a new page starts.
The first step is using PROC SQL to create a variable on every observation containing the total number of observations in the group. This is easily accomplished with the COUNT statistic.
In the subsequent DATA STEP, at the start of each group, it is decided whether the entire group will fit on the current page. This is done by retaining the number of lines already on the page and testing to see if the maximum number of lines that will fit on the page will be exceeded if the new group is output. If so, the page control variable is incremented.
In PROC REPORT, the page control variable
PGEJT becomes the first column on the report, and is defined as a GROUP NOPRINT variable. By specifying a BREAK AFTER, with a page eject, for this variable,
PROC REPORT will automatically start a new page.
/*** Count number of items in each group and put that number on each row *.,/
PROCSQL;
CREATE VlEW VlEWI AS
SELECT " COUNT(BUSFUNID) AS GRPTOT
FROM TABLE I
GROUP BY MENUNUM
ORDER BY MENUNUM, BUSFUNID;
QUIT;
/". When a new group starts, if there is not enough room for the entire group, increment the page eject variable , •• /
DATA REPDATA; SET VlEWI; BY MENUNUM;
RETAIN LNSONPGO MAX46 PGEJT I;
IF FIRST.MENUNUM THEN DO;
LNSONPG = LNSONPG + GRPTOT +3; " +3 IS TO COMPENSATE FOR BREAK LINES;
IF LNSONPG > MAX THEN DO;
PGEJT = PGEJT + I;
LNSONPG = GRPTOT + 3;
END; END; RUN;
/ •• , Use the page eject variable as a noprint break variable in the report step •• */
OPTIONS LS=130 PS=54 PAGENO=] MISSING='-' NODATE;
PROC REPORT DATA=REPDATA SPLlT= .. • .. MISSING CENTER NOWINDOWS SPACING=3;
TITLEl "Sample report using page control method";
FOOTNOTE] "Produced by Quality Assurance Reporting and Systems";
COLUMN PGEJT MENUNUM BUSFUNID VOL_TOT VOL_MET VOL_REI;
DEFINE PGEJT / GROUP NOPRINT;
DEFINE MENUNUM / GROUP FORMA T=8 . "GROUP'LEVEL'V ARlABLE*--";
DEFINE BUSFUNID / GROUP FORMAT=Z8. WlDTH=IO "ELEMENTARY'VARIABLE*--";
DEFINE VOL_TOT / SUM FORMAT=COMMA7. "TOTAL*VOLUME*CMPLTD*--";
DEFINE VOL_MET / SUM FORMAT=COMMA7.
DEFINE VOL_REI/SUM FORMAT=COMMA7.
BREAK AFTERPGEJT /PAGE;
"CMPLTD*WITHIN*STDRD*--";
"TOTAL*VOLUME*REJCTD*--";
BREAK AFTER MENUNUM / OL SUMMARIZE SUPPRESS SKIP;
RUN;
457
SAMPLE REPORT WITHOUT PAGE CONTROL pgl
GROUP
LEVEL
VARIABLE
73
ELEMENTARY
VARIABLE
00030000
00030001
00030004
00030005
00030008
TOTAL
VOLUME
CMPLTD
74
147
29
2
45
297
CMPLTD
WITHIN
STDRD
71
142
10 o o
223
82
121
00034000
00050010
2,294
2,294
147
147
2,247
2,247
141
141
122 00050020 847 838
00050030 96 89
I
I
244 00100040
7,065
38,614
2,594
38,467
Produced by . . . Reporting and Systems I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
SAMPLE REPORT WITHOUT PAGE CONTROL pg2
GROUP TOTAL CMPLTD
LEVEL ELEMENTARY VOLUME WITHIN
VARIABLE VARIABLE CMPLTD STDRD
244
365
366
00100050
00150010
00150020
00150030
00150040
00150050
00150060
00150080
00150090
6,112 6,073
44,726 44,540
400
66
73
197
6
742
10
526
36
572
303
30
17
10
5
365
6
429
33
468
Produced by ... Reporting and Systems
SAMPLE REPORT USING PAGE CONTROL pg 1
GROUP
LEVEL
VARIABLE
73
82
121
122
ELEMENTARY
Produced by
TOTAL
VOLUME
CMPLTD
WITHIN I
I
I
SAMPLE REPORT USING PAGE CONTROL pg 2
GROUP TOTAL
LEVEL ELEMENTARY VOLUME
CMPLTD
WITHIN
VARIABLE
00030000
00030001
00030004
00030005
CMPLTD
74
147
29
2
STDRD
71
142
10 o o
I
I
I
I
I VARIABLE
244
VARIABLE CMPLTD
00100050 6,112
STDRD
00100040 38,614 38,467
6,073
44,726 44,540
00030008 45
297 223
I
I
I
I
365 00150010
00150020
00150030
400
66
73
303
30
17
00034000 2,294 2,247 00150040 197 10 I
2,294 2,247
I
I
I
00150050 6
742 365
00050010 147 141 I
147 141
I
I
366 00150060
00150080
10
526
00050020 847 8~8
.
00050030 96
7,065 2,594
I
Reporting and Systems I
I
I I 00150090 36
572
33
468
Produced by . . . Reporting and Systems
6
429
5
AUTHOR CONTACT INFORMATION: Cynthia A. Stetz
Merrill Lynch - Quality Assurance Group
265 Davidson Avenue, -Somerset, NJ 08873
Phone (908) 764-1024 Internet cynthia_stetz@ml.com
458