Monday, October 2, 2017

Hack 6.3 Customizing Footnotes For More Professional Looking Reports



SAS Programming Professionals,

Did you know that you can make your reports look more professional by customizing the footnotes?

Sometimes, too much information at the top of a report can make it look a bit cluttered.  SAS-generated reports often have the date and time they were created, as well as the page number, on the upper right-hand side of their pages.  They also tend to have several lines of titles describing the general content of the report.

Wouldn’t it be cleaner to put the report’s creation date and page numbers on the bottom?  And, wouldn’t it be nice to show your clients which relative page they are viewing by having “page x of y” as the page specification?  If the answer to both of these questions is “Yes”, then take a look at this example:

ods pdf file="c:\temp\car_report.pdf";
ods escapchar="^";

options nodate nonumber;

proc print noobs data=sashelp.cars;

      var make model msrp;

title "Important Cars Report";

footnote1 j=l '^{thispage} of ^{lastpage}' j=r "Report Date: 

%sysfunc(date(),worddate.)";

run;

ods pdf close;

We start off with an ODS statement that specifies a new PDF document that will house our report.  The second ODS statement specifies the ESCAPECHAR—a symbol telling ODS that what follows is an instruction, not something to be printed.  The OPTIONS statement directs SAS to not write the date/time and page number at the top of the report.  Less clutter!

The important action takes place in the FOOTNOTE statement:

·        j=l tells SAS to left justify the following section of the footnote.


·        ‘^{thispage} of ^{lastpage}’ – the THISPAGE function inserts the current page number; the LASTPAGE function inserts the last page number.

·        j=r specifies for the following section of the footnote  to be right justified.

·        "Report Date:  %sysfunc(date(),worddate.)" – surfaces the current date and formats that date using the WORDDATE format.

Copy the example, above into a SAS Display Manager Session and give it a test drive.  Nice report, eh?  Note the cleaner look at the top and the more professional look at the bottom.  Maybe you can use this technique to improve the look of some of your own projects’ reports!

Best of luck in all your SAS endeavors!


---MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)
Author of the new cult classic for computer programmers:  It Only Hurts When I Hit <ENTER>
Print edition:  http://tinyurl.com/z8bzx2e 
Kindle edition: http://tinyurl.com/zypgqa7 

The hack above is an excerpt from the book:  Did You Know That?  Essential Hacks for Clever SAS Programmers

No comments:

Post a Comment