Monday, October 30, 2017

Hack 6.5 Jazzing Up Reports Using ODS Style Templates



SAS Programming Professionals,

The Output Delivery System (ODS) utilizes style templates (sometimes called “style definitions”) to render output.  Style templates describe the font face, size, color, and other attributes that are to be used when a report is rendered.  SAS currently has 58 individual style templates available for your use; and more are sure to be added moving forward.  If you do not specify a style template in your SAS program, ODS uses the aptly named Default style template.  Most of the time, Default is satisfactory.  However, there are some very nice alternatives!

You can get a listing of all of the style templates available to you by submitting the following:

proc template;

list styles;

run;

The output looks, in part, like this:

       Obs    Path                         Type
       -----------------------------------------
       1     Styles                       Dir
       2     Styles.Analysis              Style
       3     Styles.Astronomy             Style
       4     Styles.Banker                Style
       5     Styles.BarrettsBlue          Style
       6     Styles.Beige                 Style
       .     ...                            ...

…where the style templates are Analysis, Astronomy, Banker, etc.

To see the effect of changing the style template, first copy the following code into a SAS session, run it, and look at the resulting RTF file:

options nodate nonumber;

ods Listing close;
ods RTF  file="c:\temp\Class_Report.rtf”;

    proc print data=sashelp.class  noobs n;
      title1 "Report of Class Weight/Height Study";
    run;

ods RTF close;
ods Listing;

Not bad.  No surprises there, right?

Now, run this code that has the Astronomy style template specified:

options nodate nonumber;

ods Listing close;
ods RTF  file="c:\temp\Class_Report.rtf" style=astronomy;

    proc print data=sashelp.class  noobs n;
      title1 "Report of Class Weight/Height Study";
    run;

ods RTF close;
ods Listing;

Very nice departure from the default, isn’t it?  Well, you have 56 more styles (…because one style is the Default; which you previously used) to try, so I am sure that you will find one that is just perfect for your team and your client!

It’s nice to see a bit of color in your reports, isn’t it?

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