ODS Primer Enio Presutto York University September 21, 2001 Legal Stuff • The Presenter, The SAS Institute, and the Management of BCE Place assume no responsibility if someone gets hit by flying raisins, chocolate Bars, etc. For Your Information • GLASGOW, Scotland (Reuters) -- Good news for chocoholics. The treat favored by millions is also good for you, researchers said on Monday. Chocolate contains compounds called flavonoids that can help maintain a healthy heart and good circulation and reduce blood clotting -- which can cause heart attacks and strokes. "More and more, we are finding evidence that consumption of chocolate that is rich in flavonoids can have positive cardiovascular effects," Carl Keen, a nutritionist at the University of California, Davis, told a science conference here. "We not only have observed an increase in antioxidant capacity after chocolate consumption, but also modulation of certain compounds which affect blood vessels." Antioxidants are substances that help reduce the damage of cancer-causing charged particles in the body. Fruits, vegetables, nuts and whole grains are high in antioxidant vitamins such as C and E. Not all chocolate created equal Flavonoids in chocolate are derived from cocoa, which is rich in the compounds. Research has shown that a small bar of dark chocolate contains as many flavonoids as six apples, 4.5 cups of tea, 28 glasses of white wine and two glasses of red. ODS - What is it? • In previous versions of SAS Datastep and procedures produced output directly • Output was produced for mainframe printing using line printers (monospaced fonts) • Graphics were produced for plotters • Very little control over appearance ODS – Output Delivery System • Scopo della giornata di corso è quello di introdurre le tecniche per utilizzare questa nuova funzionalità disponibile con la Versione 8 di SAS per la produzione di output (listati, tabelle, pagine HTML, dataset SAS) e la generazione di template e stili per la produzione automatica di questi tipi di output. ODS – Output Delivery System • Version 8 saw introduction of ODS • Datastep and procedures now produce output objects • ODS processes these output objects and produces required output • ODS can produce in the following formats HTML, PDF, RTF, CSV, JPEG, GIF, Postscript, XML, etc. ODS – Proc Print before ODS • proc print data=tass.tass(obs=5); • run; ODS – Proc Print before ODS The SAS System Obs number Title 1 1 Hello Mary Lou/Travelin' Man 2 2 I'm Gonna Knock On Your Door 3 3 Big Bad John 4 4 Crying/Candy Man 5 5 You're The Reason Obs Artist year 1 Ricky Nelson 1961 2 Eddie Hodges 1961 3 Jimmy Dean 1961 4 Roy Orbison 1961 5 Bobby Edwards 1961 ODS – Proc Freq before ODS proc freq data=tass.tass(obs=20); tables artist; run; • • • • • Output produced is suitable for line printers is monospaced Only one great font No colour Limited to 133 columns ODS – Proc Freq before ODS The SAS System The FREQ Procedure Artist Cumulative Cumulative Artist Frequency Percent Frequency Percent ----------------------------------------------------------------------------Andy Stewart 1 5.00 1 5.00 Beau-Marks 1 5.00 2 10.00 Bobby Edwards 1 5.00 3 15.00 Chubby Checker 1 5.00 4 20.00 Clarence "Frogman" Henry 1 5.00 5 25.00 Del Shannon 1 5.00 6 30.00 Dion 1 5.00 7 35.00 Eddie Hodges 1 5.00 8 40.00 Elvis Presley 1 5.00 9 45.00 Everly Brothers 1 5.00 10 50.00 Highwaymen 1 5.00 11 55.00 Jimmy Bell 1 5.00 12 60.00 Jimmy Dean 1 5.00 13 65.00 Marcells 1 5.00 14 70.00 Neil Sedaka 1 5.00 15 75.00 Patsy Cline 1 5.00 16 80.00 Ramrods 1 5.00 17 85.00 Ricky Nelson 1 5.00 18 90.00 Roy Orbison 1 5.00 19 95.00 String-A-Longs 1 5.00 20 100.00 ODS – Defaults • Version 8 procedure output defaults to ODS LISTING destination • No changes required to your program ODS – HTML Destination • • • • • • • ods listing close; filename results 'd:\2001-09-21 tass\saspgms\html1.html'; ods html body=results; proc print data=tass.tass(obs=5); run; ods html close; run; • View Results ODS – HTML Destination • • • • • • • ods listing close; ods html body='d:\2001-09-21 tass\saspgms\html1.html' (title='Proc Print to HTML'); proc print data=tass.tass(obs=5 ); run; ods html close; run; • Title option changes text used in browser title bar • View Results ODS – HTML Destination • • • • • • • • • • • ods listing close; ods html body='d:\2001-09-21 tass\saspgms\html3.html' (title='Proc Print to HTML'); title 'T.A.S.S. September 2001 - ODS Presentation'; proc print data=tass.tass(obs=5); run; proc freq data=tass.tass(obs=10); tables artist; run; ods html close; run; • View Results ODS – HTML Destination • • • • • • • • • • • • • • • ods listing close; ods html body='d:\2001-09-21 tass\saspgms\html4-body.html' contents='d:\2001-09-21 tass\saspgms\html4-contents.html' frame='d:\2001-09-21 tass\saspgms\html4-frame.html'; (title='Proc Print to HTML'); title 'T.A.S.S. September 2001 - ODS Presentation'; title2 'Proc Print output'; proc print data=tass.tass(obs=5); run; title2 'Proc freq output'; proc freq data=tass.tass(obs=10); tables artist; run; ods html close; run; • View Results ODS – HTML Destination • • • • • • • • • • • • • • • • • ods listing close; ods html body='d:\2001-09-21 tass\saspgms\html5-body.html' contents='d:\2001-09-21 tass\saspgms\html5-contents.html' frame='d:\2001-09-21 tass\saspgms\html5-frame.html'; (title='Proc Print to HTML'); title 'T.A.S.S. September 2001 - ODS Presentation'; title2 'Proc Print output'; ods proclabel 'Listing of Songs'; proc print data=tass.tass(obs=5); run; title2 'Proc freq output'; ods proclabel 'Frequency Report'; proc freq data=tass.tass(obs=10); tables artist; run; ods html close; run; • View results ODS – HTML Destination • • • • • • • • • • ods listing close; ods html body='d:\2001-09-21 tass\saspgms\html6.html' (title='Proc Print to HTML'); title '<h1>Song titles taken from 1050 Chum Charts</h1>'; proc print data=tass.tass(obs=5 ) noobs label; var title artist year; label artist='<i><font color=red>Artist Name</font></i>'; run; ods html close; run; • View results ODS – HTML Destination • • • • • • ods listing close; goptions device=gif; ods html body='d:\2001-09-21 tass\saspgms\html7.html' (title='Proc Print to HTML' no_bottom_matter); title '<h1>Song titles taken from 1050 Chum Charts</h1>'; NOTES: • No_bottom_matter – tells ods not to generate closing html tags ODS – HTML Destination • proc print data=tass.tass(obs=5 ) noobs label; • var title artist year; • label artist='<i><font color=red>Artist • • Name</font></i>'; run; ods html close; Notes • Ods destination is closed ODS – HTML Destination • filename graphic 'd:\2001-09-21 tass\saspgms\html7.html' mod; • title 'Song titles taken from 1050 chum charts'; • ods html file=graphic (no_top_matter) • gpath='d:\2001-09-21 tass\saspgms\' • (url=none); NOTES • Use filename to append to html file created on previous page • Use no_top_matter to tell ods not to generate opening tags in html file • (url=none) – tells ods not to use URLs, but to use filenames instead, it you specify a url then ods will use it to build the html page names ODS – HTML Destination • proc gchart data=tass.tass; • vbar3d year / • name='Year Recorded'; • run; quit; • ods html close; • run; • View Results ODS – RTF destination • ods listing close; • filename results 'd:\2001-09-21 • • • • • tass\saspgms\rtf1.rtf'; ods rtf file=results; proc print data=tass.tass(obs=5); run; ods rtf close; run; • View results ODS – RTF destination • • • • • • • • libname tass 'D:\2001-09-21 tass\sasdata'; run; ods listing close; filename results 'd:\2001-09-21 tass\saspgms\rtf2.rtf'; proc format; value traffic low-100000 = 'cxCC0000' /* green */ 100001-240000='cxFF9900‘ /* yellow */ 240001-high= 'cx006600‘ ; /* red */ • Note • Traffic lighting run; ODS – RTF destination • • • • • • • • • ods rtf file=results; proc tabulate data=tass.popular; class name /STYLE=[FONT_FACE="Times New Roman"]; var amount /STYLE=[FONT_FACE="Helvetica"]; tables name='Item Name' all, amount='Amount Sold'*sum* [STYLE=[FOREGROUND=TRAFFIC. FONT_WEIGHT=bold]]; run; ods rtf close; run; • View Results ODS – PDF destination • • • • • • • • • • • • • libname tass 'D:\2001-09-21 tass\sasdata'; run; ods listing close; filename results 'd:\2001-09-21 tass\saspgms\pdf2.pdf'; ods pdf file=results notoc; proc tabulate data=tass.popular; class name /STYLE=[FONT_FACE="Times New Roman"]; var amount /STYLE=[FONT_FACE="Helvetica"]; tables name='Item Name' all, amount='Amount Sold'*sum* [STYLE=[FOREGROUND=TRAFFIC. FONT_WEIGHT=bold]]; run; ods pdf close; run; • View results References Output Delivery System By Lauren E. Haworth