Friday, July 15, 2016

Hack 3.13 Inserting Blank Lines in PROC PRINT Output

SAS Programming Professionals,

Did you know that you can make PRINT procedure output more readable by inserting blank lines?

If you are still tethered to using good old PROC PRINT to create reports for your users, then you know how crowded some of the listings can be when you have a lot of data to print.  The BLANKLINE option of PROC PRINT allows you to insert a blank line every N rows.  Here is an example:

proc sort data=sashelp.class out=class;
      by sex;
run;

proc print noobs data=class sumlabel blankline=5;
     
by sex;

sum weight height;

label sex = "Gender";

title1 "Class Roster By Gender";

run;

The BLANKLINE option on our PROC PRINT statement specifies for SAS to insert a blank line after every five lines of output.  The result looks, in part, like this:

Gender=F
Name
Age
Height
Weight
Alice
13
56.5
84.0
Barbara
13
65.3
98.0
Carol
14
62.8
102.5
Jane
12
59.8
84.5
Janet
15
62.5
112.5

Joyce
11
51.3
50.5
Judy
14
64.3
90.0
Louise
12
56.3
77.0
Mary
15
66.5
112.0
Gender

545.3
811.0

Notice the nice blank line between Janet and Joyce.  I like to set the value to either 10 or 20 on those rare occasions when I am creating long listings with PROC PRINT.  I wonder what value you will end up using.

Best of luck in all your SAS endeavors!

----MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)

Excerpt from the book:  Did You Know That?  Essential Hacks for Clever SAS Programmers

I plan to post each and every one of the hacks in the book to social media on a weekly basis.  Please pass them along to colleagues who you know would benefit.

No comments:

Post a Comment