Title: ODS for PRINT, REPORT,
1ODS for PRINT, REPORT, TABULATE
- Lauren HaworthGenentech, Inc., South San
Francisco
2Why are these PROCs Special?
- For most procedures you must use PROC TEMPLATE to
change your output style - PRINT, REPORT, and TABULATE allow you to change
the output style attributes on the fly when the
output is generated
3This paper will show how to ...
- Change the fonts, colors, and alignment of your
output - Use formats to highlight key results in special
colors - Add images to table headings
4Output destinations
- For convenience, all of the examples are shown as
HTML output - Except where noted, the examples work for RTF or
printer output as well
5SAS versions
- Based on SAS version 8.2
- PRINT examples require 8.2
- REPORT and TABULATE examples will also work with
versions 8.0 and 8.1
6The STYLE option
- Specify different style attributes for specific
parts of your output. - Style attributes control things like
- typefaces
- foreground and background colors
- text alignment
- table border styles
7Changing Table Heading Styles for PROC PRINT
- Start with a simple table of data
-
- ODS HTML FILE'tables.htm' proc print
datatables noobs label var Type Material
Price run - ODS HTML CLOSE
8Original Table
(remaining rows not shown)
9Adding the STYLE option
STYLE option
Style element
- ODS HTML BODY'tables.htm' proc print
datatables noobs label STYLE(Header)FONT_FA
CEArial Narrow var Type Material Price
runODS HTML CLOSE
Value
Style attribute
10Resulting table
Original
New
11Changing Table Heading Styles for PROC REPORT
- Start with a table similar to the previous
example. - ODS HTML BODY'tables.htm' proc report
datatables nowd column Type Material
Price define Type / group define
Material / group define Price / analysis
mean runODS HTML CLOSE
12Original Table
13Adding the STYLE Option
- Same technique as with PROC PRINT
- ODS HTML BODY'tables.htm' proc report
datatables nowd STYLE(Header)FONT_FACEAr
ial Narrow column Type Material Price
define Type / group define Material /
group define Price / analysis mean
runODS HTML CLOSE
STYLE option
Style element
Value
Style attribute
14Resulting Table
Original
New
15Changing Table Heading Styles for PROC TABULATE
- Start with a table similar to the previous
example. - ODS HTML BODY'tables.htm' proc tabulate
datatables fdollar8. class Type
Material var Price table
TypeMaterial, PriceMean" "
runODS HTML CLOSE
16Original Table
17How to Specify Style
- TABULATE syntax is different
- Specify styles for the row and column headings in
the VAR and CLASS statements
18Specifying the STYLE Options
- ODS HTML BODY'tables.htm' proc tabulate
datatables fdollar8. class Type Material
/ STYLEFONT_FACE"Arial Narrow"
var Price / STYLEFONT_FACE"Arial
Narrow" table TypeMaterial,
PriceMean" " runODS HTML CLOSE
Value
Style attribute
STYLE option
19Resulting Table
Original
New
20Fixing the Remaining Row Headers
- ODS HTML BODY'tables.htm' proc tabulate
datatables fdollar8. class Type Material
/ STYLEFONT_FACE"Arial Narrow"
classlev Type Material /
STYLEFONT_FACE"Arial Narrow" var Price
/ STYLEFONT_FACE"Arial Narrow"
table TypeMaterial, PriceMean" "
runODS HTML CLOSE
21Revised Results
First version
Revised
22Applying Traffic Lighting to PROC PRINT
- What do traffic lights have to do with SAS
Output? - Redbad resultsYellowneutral resultsGreengood
results - Great for focusing the readers attention on the
key results.
23Step 1 Set up a Format for Colors
- proc format value traffic
low-100'cx00CC33'
100lt-300'cxFFFF66'
300lt-high'cxFF3300'run
24Step 2 Use the Format with STYLE
- ODS HTML FILE'tables.htm' proc print
datatables noobs label var Type Material
var Price / STYLEBACKGROUNDtraffic.
runODS HTML CLOSE
25Resulting Table
- Warning Notice that amounts are no longer
formatted as dollars. This is to get around a
v8.2 bug that affects using formats to apply
styles in PROC PRINT.
26Step 3 Fix the Font Weights
- With color background, numbers hard to read
- ODS HTML FILE'tables.htm'proc print
datatables noobs label var Type Material /
STYLEFONT_WEIGHTBOLD var Price /
STYLEBACKGROUNDtraffic.
FONT_WEIGHTBOLDrunODS HTML CLOSE
27Resulting Table
28Reversing the Effect
- You can also do traffic lighting with colored
numbers instead of colored backgrounds. - Change BACKGROUND to FOREGROUND
- var Price / STYLEFOREGROUNDtraffic.
FONT_WEIGHTBOLD
29Same Table with FOREGROUND Colors
30Applying Traffic Lighting to PROC REPORT
- ODS HTML BODY'tables.htm' proc report
datatables nowd column Type Material
Price define Type / group
STYLEFONT_WEIGHTBOLD define Material /
group STYLEFONT_WEIGHTBOLD
define Price / analysis mean
STYLEBACKGROUNDtraffic.
FONT_WEIGHTBOLD runODS HTML CLOSE
31Resulting Table
32Same Table with FOREGROUND Colors
33Applying Traffic Lighting to PROC TABULATE
- ODS HTML BODY'tables.htm' proc tabulate
datatables fdollar8. class Type
Material var Price table
TypeMaterial, PriceMean" "
STYLEBACKGROUNDtraffic.
FONT_WEIGHTBOLD runODS HTML CLOSE
34Resulting Table
35Same Table with FOREGROUND Colors
36Creating Alternate Row Shading
- Technique for PROC REPORT
- Alternate gray and white row backgrounds
- Makes table easier to read
37Using STYLE in the COMPUTE Block
- ODS HTML BODY'tables.htm' proc report
datatables nowd column Type Material
Price define Type / group define
Material / group define Price / analysis
mean compute Material count1
if (mod(count,2)) then do CALL
DEFINE(_ROW_, "STYLE",
"STYLEBACKGROUNDcxFFFFFF") end
endcomp runODS HTML CLOSE
38Resulting Table
39Adding a Logo Graphic to PROC REPORT Step 1
- ODS HTML BODY'tables.htm' proc report
datatables nowd column Type Material
Price define Type / group define
Material / group define Price / analysis
mean compute before _page_ / LEFT
LINE "Totally Tables, Inc." endcomp
runODS HTML CLOSE
40Resulting Table
41Adding a Logo Graphic to PROC REPORT Step 2
- compute before _page_ / LEFT
STYLEPREIMAGE'table.gif'
FONT_WEIGHTBOLD FONT_SIZE5
FOREGROUNDcx993300 LINE "Totally
Tables, Inc."endcomp
- Note This example is set up for HTML output, and
gives the font size using a number which
represents an HTML font size. If you are creating
RTF or printer output, list the font size in
points (for example, 14pt).
42Resulting Table
43Adding a Logo to PROC TABULATE
- ODS HTML BODY'tables.htm' proc tabulate
datatables fdollar8. class Type
Material var Price table
TypeMaterial, PriceMean" " /
BOXLABEL'Totally Tables, Inc.'
STYLEPREIMAGE'dining.gif' runODS HTML
CLOSE
Original Label
Extra Brackets
Attribute
STYLE option
44Resulting Table
45Fixing the Heading Alignment
- ODS HTML BODY'tables.htm' proc tabulate
datatables fdollar8. class Type
Material var Price / STYLEVJUSTB
table TypeMaterial, PriceMean" "
/ BOXLABEL'Totally Tables, Inc.'
STYLEPREIMAGE'dining.gif' runODS HTML
CLOSE
46Revised Table
47Modifying the Entire Table
- You can use STYLE to change the font, color,
etc. for the entire table - Syntax
- PROC REPORT DATAdataset STYLEstyle-attribut
e(s) - PROC PRINT DATAdataset STYLEstyle-attribut
e(s)
48Modifying the Entire Table
- Syntax for PROC TABULATE
- TABLE ltltpage-definition,gt row-definition,gt
column-definition / STYLEstyle-attribute(
s)
49Other Style Attributes
- Dozens of style attributes you can modify
- Many places to use them within each procedures
output
50Experiment
- Try the various style attributes
- Try the various places you can use STYLE
- Get creative, especially with the COMPUTE block
in PROC REPORT
51To Learn More
- Check out the examples in the Guide to the SAS
Output Delivery System in the Online
Documentation - Some more examples are in my new book Output
Delivery System The Basics - Next year, look for Output Delivery System
Advanced Topics
52Conclusion
- The possibilities for output enhancement are
endless. - Have fun with these techniques.
53Thanks for Coming!
- Lauren Haworth
- info_at_laurenhaworth.com