Usage Note 31366: Inserting a Blank Line After Every N Observations in PROC PRINT Output Using SAS 9.2
Even beginning SAS programmers are familiar with PROC PRINT due to the minimal syntax required to produce simple listing reports. However, customized reports can be somewhat challenging. A basic listing report in which a blank line is inserted after every n rows may be a bit easier to read, but it is particularly challenging to create.
One traditional technique to solve this problem is to insert additional observations at a regular interval, each of which contains all missing values. The default display of a numeric missing value as a period is overridden by setting the MISSING system option to a blank.
/* Insert blank observation after every 5 observations */
data class_blanks;
set sashelp.class;
output; /* Output real observation */
if mod(_n_,5)=0;
array allnums {*} _numeric_ ;
array allchar {*} _character_ ;
drop i;
do i=1 to dim(allnums); allnums{i}=.; end;
do i=1 to dim(allchar); allchar{i}=' '; end;
output; /* Output blank observation */
run;
options missing=' '; /* Display numeric missing as blank */
proc print data=class_blanks noobs;
title 'SASHELP.CLASS with Blank Line After Every 5 Obs';
run;
One minor disadvantage to this approach is that the observation number column must be suppressed.
The PRINT procedure supports the BLANKLINE= option in SAS 9.2. The simplest form of the option specifies the number of observations to display before each blank line.
The observation number column can be displayed with the BLANKLINE= option.
/* The BLANKLINE option accomplishes the same result */
proc print data=sashelp.class blankline=5;
title 'SASHELP.CLASS with Blank Line After Every 5 Obs';
run;
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 2000 Advanced Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Professional | 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 | |
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 note reviews aseemingly simple problem that gets substantially easier to solve using new features of the Base SAS 9.2 PRINT procedure. The note is adapted from
Don't Be a SAS Dinosaur: Modernize Your SAS Code by Warren Repole, SAS Institute.
Type: | Usage Note |
Priority: | |
Topic: | SAS Reference ==> Procedures ==> PRINT
|
Date Modified: | 2008-03-25 13:12:44 |
Date Created: | 2008-03-03 13:32:35 |