Usage Note 53783: GROUP or ORDER variables in PROC REPORT might not repeat with the SPANROWS option if BREAK or LINE statements are used
The SPANROWS option in PROC REPORT can be used to repeat the value of a GROUP or ORDER variable when it crosses a page boundary in the ODS PDF, PS, and Tagsets.RTF destinations.
However, the value of the GROUP or ORDER variable might not be repeated when a BREAK or LINE statement is used. A row created by a BREAK or LINE statement introduces its own cell in the column. This action breaks the spanning cell into two cells even when the value of the GROUP or ORDER variable that comes after the summary row is unchanged. The value is cleared out and therefore cannot be repeated after the BREAK or LINE row.
The Full Code tab demonstrates this behavior as well as a possible workaround. The workaround is to hold the value of the GROUP or ORDER variable in a data step or temporary variable and then reset the value if it has been cleared out.
Operating System and Release Information
| SAS System | Base SAS | z/OS | 9.2 TS1M0 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
| Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
| Microsoft® Windows® for x64 | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
| Microsoft Windows XP Professional | 9.2 TS1M0 | |
| Windows Vista | 9.2 TS1M0 | |
| Windows Vista for x64 | 9.2 TS1M0 | |
| 64-bit Enabled AIX | 9.2 TS1M0 | |
| 64-bit Enabled HP-UX | 9.2 TS1M0 | |
| 64-bit Enabled Solaris | 9.2 TS1M0 | |
| HP-UX IPF | 9.2 TS1M0 | |
| Linux | 9.2 TS1M0 | |
| Linux for x64 | 9.2 TS1M0 | |
| OpenVMS on HP Integrity | 9.2 TS1M0 | |
| Solaris for x64 | 9.2 TS1M0 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This sample code creates a PDF file where the value of Canada is not repeated at the top of each page, starting at page 8. This is caused by the BREAK row for Region on page 7.
The subsequent section of code illustrates a possible workaround, which is to use a hold variable and reset the GROUP or ORDER value where necessary.
/* Illustrate the Country variable not repeating at the top of each page */
options nodate;
ods pdf file='spanrows_does_not_repeat.pdf' notoc;
title 'Canada does not repeat at the top of page 8';
proc report data=sashelp.prdsale spanrows;
where country = 'CANADA';
column country region division prodtype product quarter year month actual;
define country / order ;
define region / order ;
define quarter / order ;
define year / order ;
define month / display;
define actual / sum format=dollar16.2;
break after country / summarize page;
break after region / summarize;
run;
ods pdf close;
/* Illustrate the workaround of using the PAGE option in the BREAK statement */
options nodate;
ods pdf file='workaround_for_spanrows.pdf' notoc;
title 'Canada does repeat at the top of all pages';
proc report data=sashelp.prdsale spanrows;
where country = 'CANADA';
column country prtcntry region division prodtype product quarter year month actual;
define country / order ;
define prtcntry / computed noprint;
define region / order ;
define quarter / order ;
define year / order ;
define month / display;
define actual / sum format=dollar16.2;
break after country / summarize page;
break after region / summarize;
compute before country;
length hold $10;
hold = country;
endcomp;
compute prtcntry / character length=10;
prtcntry = hold;
** in the compute block for prtcntry, we can assign a value to COUNTRY;
** COUNTRY will ALWAYS be blank on the row after the subtotal for REGION;
if country = ' ' then country = hold;
endcomp;
run;
ods pdf close;
Click Here to view the file demonstrating the GROUP variable not repeating at the top of each page.
Click Here to view the file demonstrating the workaround.
The SPANROWS option in PROC REPORT can be used to repeat the value of a GROUP or ORDER variable when it crosses a page boundary in the PDF, PS, and Tagsets.RTF destinations. The value might not repeat if a BREAK or LINE statement is used.
| Type: | Usage Note |
| Priority: | medium |
| Date Modified: | 2014-08-05 13:25:10 |
| Date Created: | 2014-07-30 10:51:13 |