Lesson 44: ODS
Video: Traffic Lighting
Use ODS to send output to different destinations, e.g.:
This ods command creates an external file with the given path and filename.The "ods html close" command is important here. Any time you want to create a file, whether html, pdf, or anything else, the file on the disk is not closed until the ods close command is issued. This has two results, 1. You cannot open it with an outside program, and 2. If more output is generated, say by running the procedure again, the new output will be added to the file.
SAS will not overwrite these files if they are open in either the results viewer or Excel (externally). So you must remember to close the document in Excel or in the Results Viewer before running the program again.
The results viewer opens this like an Excel file because of the xls extension, and the file can be double-clicked and opened in Excel directly. It is actually an html file, though. Excel knows how to open html files. It will not become an Excel file unless you go "Save As" and save it in Excel format.
You can apply different styles to change the appearance of the output. Use the "minimal" style to keep the formatting simple for later modification in Excel. There are many styles available, although not all are useful for html. Refer to the lesson on ODS or ODS documentation for more information about styles.
Use ODS select to choose which tables to print. Use ODS output to send an output table (or object) to a SAS data set.
Now you can use proc print to print it, using only the desired variables, and sending the output to html or an excel file.
You can format titles, such as:
You can also use proc report instead of proc print.
Proc report allows greater control of the output, and in particular will allow us to do "Traffic Lighting." In html the column headings won't automatically split like they do in the output window, so a split character can be added to accomplish that.
Use "traffic lighting" to change colors of different p-values or highlight whole rows. In the define statement for a variable, you can put a style command like this:define probt/display "P-/Value" style=column[foreground=red
This will change the appearance of a whole column. However we would like the change to apply only to certain rows. In order to do this, we introduce another feature of proc report, the compute block. But even before that, we need to define a format, since the p-value is a continuous variable. We want to define the ranges that our traffic lighting will affect.
Now use the format by putting it in place of the color in the define statement. We also take out the background color here. You could make another format to assign contrasting colors to the background.
Copyright reserved by Dr. Dwight Galster, 2009. Please request permission for reprints (other than for personal use) from email@example.com . "SAS" is a registered trade name of SAS Institute, Cary North Carolina. All other trade names mentioned are the property of their respective owners. This document is a work in progress and comments are welcome. Please send an email if you find it useful or if your site links to it.