Specifying Output in SAS

​By Steve Graunke, Assistant Director for Survey Research and Standard Reports, Indiana University-Purdue University-Indianapolis

SAS users have access to a number of useful options for receiving output. ODS RTF is particularly useful, as it enables users to export results into rich text format (.rtf), which can easily be edited using word-processing software. To specify that output is received in .rtf requires an ods statement:

Ods rtf file=”[file destination and name].rtf”;

After entering whatever procedures you wish to perform, you will need to close the .rtf file in order to view and edit it. Closing the .rtf file will require the following statement:

Ods rtf close;

The default .rtf output will look like this:

 
Note that the default includes the page numbers and date. The page is in portrait orientation with all titles in the header of the page. By adding options statements, however, the output can be modified to fit any specification. For example, SAS has numerous style templates which define the format of text and tables within your output. To specify a style template, add a “style =” statement to the SAS statement above:
 
Ods rtf file=”[file destination and name].rtf” style=[style];
 

Of the basic SAS templates, the journal style is closest to APA specifications for tables. Output using the “style=journal” option will look like this: 



These tables could be easily edited in Word to more closely match APA or any other desired format. Alternately, individualized templates can be created using the proc template option. The code below will create a style template similar to journal, but with italics removed.

proc template;edit styles.journal as styles.newstyle;
style fonts /
'TitleFont' = (Arial,12pt,Roman)
'headingfont' = (Times,12pt,Roman)
'docFont' = (Times,12pt,Roman);end;run;

Specifying “style=newstyle” will then yield an output that looks like this:



Additional option specifications can make the output easier to edit. To bring the title out of the header and into the body of the document, use the “bodytitle” option. For example, the code:

Ods rtf file=”[file destination and name].rtf” style=journal bodytitle;

will yield output like the following:

 
Page layout can be changed by using an options statement before the ods statement. Specifying the following:
 
options orientation=landscape;
ods rtf file =”[file destination and name].rtf” style=journal bodytitle;

will yield this output:



Adding ods noproctitle; after the ods rtf statement will eliminate the procedure title, which may be beneficial when sharing output with colleagues who do not use SAS. Output using an ods noproctitle statement will look like the following:



This is only an introduction to some of the basic options available with ods rtf. Please consult the references below for further information.
 
References:
  • Delwiche, L. D. & Slaughter, S. J. (2008). The little SAS book: A Primer (4th ed.). Cary, NC: SAS Institute, Inc.
  • Matthews, C. & Kalchenko, E. (2013, May). Pretty please?! Making RTF output “pretty” with SAS (Paper IB08). Paper presented at the 2013 Annual Conference of the Pharmaceutical Inductry SAS Users Group, Chicago, Il. 
  
 

 Comments

 
To add a comment, Sign In
Total Comments: 5
 
JR posted on 2/13/2014 11:12 AM
This is interesting - as a cognos shop there are particularly annoying limitations to how our PDF rendered output looks, I do not currently use SAS but this tip makes me wonder if this approach here could lead to a way to inject SQL into my report structure to correct and overlay the set defaults that seem to plaque the PDF reports I generate - thanks for this information!
Kendra posted on 2/13/2014 11:21 AM
Steve, I am not familiar with SAS as our university uses a different reporting assistance system. Thank you for the the basic look at features used within the program.
Shabnam posted on 2/13/2014 2:05 PM
Thanks Steve for sharing this, as ODS- RTF is an handy tool and your example shows how easily in SAS one can get reports as one would like. SAS is a powerful BI tool for reporting and analytical purpose.
Lisa posted on 2/13/2014 2:53 PM
We have recently become a SAS shop. I've worked my way through SAS level one programming and SAS is really a great tool. The tip about clearing the ODS RTF formatting is critical or one might wonder what is going on with the output. The same tip will apply to clearing ODS HTML, too. With SAS, one can truly control the output. Thanks so much for the information. I will be trying this formatting very soon.
Lee posted on 2/14/2014 10:36 AM
Steve, thanks for a helpful and informative tip. I haven't used SAS in a while but it's good to see some ideas for how it can be used effectively in an IR environment.