SAS Helpful Hints
Output Delivery System(ODS)
The ODS system is used to capture SAS output and save it in SAS savesets
or HTML files. This requires a couple steps. First run your SAS program
or procedure with "Ods Trace On" and look at the log file.
The log file will list the ODS objects created. Once you know the
object names, you can use them in your program.
Example 1: Creating SAS savesets
Ods Trace On;
*Turn off default listing;
Ods Listing Select None;
*Note:You may select several objects to save in a Ods Output statement;
*This example only saves one;
Ods Output Table(Match_all
Persist=Proc)=work.mytable
(Rename=(_TYPE_=type
_PAGE_=pagenum)) ;
Proc Tabulate Data=work.A Missing;
Class color;
Var age;
Table age*(N*f=8.0 (Mean Std)*f=8.3 (Min Max)*f=8.0),(color
All) / Rts=35 Condense;
Label age='Age' color='Color';
Run;
*Turn on default listing;
Ods Listing Select All;
Ods Trace Off;
*Captured datasets are now available to use!;
Proc Contents Data=work.mytable; Run;
Proc Print Data=work.mytable; Run;

Example 2: Creating HTML files
*The default style is rather ugly. Modify the following
template to suit your own taste;
Proc Template;
Define Style mystyle;
Style Body / Background=Blue;
Style Systemtitle
/ Foreground=Yellow Font_face=Centx
Font_size=6;
Style Table / Bordercolorlight=Yellow
Bordercolordark=Gold Cellspacing=0
Borderwidth=2;
Style Header / Background=Blue
Foreground=Yellow Font_face=Centx
Font_size=5;
Style Rowheader /
Background=Blue Foreground=Yellow
Cellwidth=80 Just=Left Font_face=Centx
Font_size=5;
Style Data / Background=Blue
Foreground=Yellow Cellwidth=90
Just=Right Font_face=Centx Font_size=5;
End;
Run;
Ods Trace On;
Ods Html File='C:\TEMP\test.html'
Style=mystyle;
*Note:You may select several objects to save in a Ods Select statement;
Ods Select Table ;
Proc Tabulate Data=work.A Missing;
Class color;
Var age;
Table age*(N*f=8.0 (Mean Std)*f=8.3 (Min Max)*f=8.0),(color
All) / Rts=35 Condense;
Label age='Age' color='Color';
Run;
Ods Html Close;
Ods Trace Off;
|
Example of the
Output Delivery System
|
|
Color |
All |
| Blue |
Green |
Red |
Yellow |
Placebo |
| Age |
N |
38 |
70 |
18 |
22 |
54 |
202 |
| Mean |
47.237 |
46.229 |
41.056 |
42.136 |
43.944 |
44.901 |
| Std |
10.138 |
9.009 |
11.624 |
10.665 |
8.320 |
9.612 |
| Min |
22 |
22 |
21 |
24 |
28 |
21 |
| Max |
60 |
60 |
60 |
60 |
59 |
60 |
|
The ODS system has many features and functions not documented in this
site. I hope there is enough here to get you started.
Please send your comments and suggestions about this web page to A. Watts
(watts@bst.rochester.edu)
|