SAS ODS: {thispage} and {lastpage} and PDF Output

By | February 26, 2013

saslogo

When developing new reports, we typically give the end users a choice of output formats to choose from.  The SAS Output Delivery System (ODS) provides a versatile framework to transform the results of SAS procedures into consistent, high quality reports in formats that are widely used by information consumers: HTML (HyperText Markup Language), PDF (Portable Document Format), RTF (Rich Text Format), Microsoft Excel, and others.  The majority of our reports (run as stored processes surfaced in the SAS Information Delivery Portal) contain tabular output, which is generally displayed to a user in HTML format with the option to download that data as a Microsoft Excel spreadsheet.

Some reports are designed to be formatted as a document, and include large amounts of ODS text, tables, and graphs.  We generally use ODS functions such as {thispage}, {pageof}, or {lastpage} to display the page number or number of pages in the document.  When using RTF as our ODS destination, the creation of a Microsoft Word document could not be easier.  We did run into one issue when using the PDF output destination, however.  Due to the configuration of printer drivers on our computer systems, the page numbers were not showing up in our documents, because SAS was unable to determine a default page size and margins.  We contacted SAS Technical Support and they pointed us to SAS Problem Note 31703 as a possible fix.  Tech Support solved our problem – we added the –uprint and –uprintmenuswitch options to our autoexec.sas configuration file and restarted our object spawners and our PDF documents included page numbers!

Want to know more about the SAS Output Delivery System?  Go to the Base SAS ODS Focus Area or download the Output Delivery System Tip Sheet.

Leave a Reply

Your email address will not be published. Required fields are marked *