Differences in ODS formtting for HTML with Proc Print nd Proc Report Lur L. M. Thornton, USDA-ARS, Animl Improvement Progrms Lortory, Beltsville, MD ABSTRACT While Proc Print is terrific tool for dt checking nd dt summry, Proc Report is similr to, ut more powerful ecuse it cn do some sic clcultions or sttistics nd dt cn e roken more effectively into mngele fields. The ODS procedure cn produce HTML files from either procedure nd formtting for output is slightly different for ech. This presenttion is ment to explore few of the differences in the formtting pplied y ODS to ech procedure nd methods to produce similr HTML output. It is not ll inclusive, ut this rief demonstrtion will del specificlly with id, clss, nd y sttements within ech for output to HTML y ODS. INTRODUCTION When reporting results from SAS output to vrious udiences, often more sophisticted report is required thn the sic Proc Print output. While Proc Print cn e forced to produce desired output, Proc Report is etter reporting tool, llowing greter flexiility in hndling outputs. However, when using ODS to pulish outputs, whether to HTML or nother file, differences in the hndling of certin coding sttements occurs. The purpose of this pper is to illustrte how ech procedure works with ODS nd illuminte the differences in code hndling in order to llow for etter selection of proper reporting tools. OUTPUT DELIVERY SYSTEM Vrious methods to produce sophisticted output exist, ut ODS mkes it esy to output to HTML, Excel, or other files. The HTML ppliction produces redy to pulish HTML code nd provides source informtion for esy dditions or ltertions to we pges. Simple ODS code requires opening nd closing rguments nd cn e used with most SAS procedures. A simple exmple of how ODS works is: ods pth work.templte(updte) sshelp.tmplmst(red) lirry.templt(red); ods html file = pthnme ; style = stylesheetnme; title New dt sheet ; Proc Print dt=one_set; id vr1 vr2 vr3; Proc Report dt = two_set; column vr4 vr5 vr6; define vr4 / (no.) ; The code contined within the ODS output cluse is reltively simple to put together s it uses code lredy known. The only chnges re the inclusion of pths for files nd templtes nd style sheet guideline, if one exists. The ODS environment must e opened nd closed Additionlly, with ODS HTML, HTML3 cn e used to revert to the HTML 3.2 formtting (which my e desirle when using older style sheets). PROC PRINT Proc Print is often used to do simple reporting of results, ut cn e used to crete HTML tles when used in conjunction with ODS. Use of id nd y sttements helps to produce some desired outputs. The use of the id sttement sets up the columns tht will e displyed nd the style sheet in use defines how those columns will e displyed. The first column is designted s column, rther thn s row delinetion. The clss sttement is used to delinete etween different groups (or clsses) of vriles. The y sttement cn lso e used s n dditionl seprtion scheme similr to how it is used in Proc Mens or other SAS procedures; however, it is of note tht dt sets must e sorted y the vriles in the y sttement for y to e used properly. Using the previous exmple nd expnding on the level of sophistiction in the output: ods pth work.templte(updte) sshelp.tmplmst(red) lirry.templt(red); ods html file = pthnme ; style = stylesheetnme; title New dt sheet ; Proc Print dt=one_set; 1
id vr1 vr2 vr3; y vr vr; clss vrx vry; This would produce nicely styled tle with little dditionl formtting in simple type fce set to those defined in the style sheet. No individul control of columnr or row formtting is ville within the Proc Print commnd. The output would e divided into prts of vr nd vr (the y vriles) nd ech division would hve further prtitions of vrx nd vry (the clss vriles) with columns of vr1, vr 2, nd vr 3 (tle 1). While not prticulrly spectculr, it is functionl for simple reporting. Tle 1. Simple Proc Print output using previously defined style sheet. Vr Vrx Vr1 Vr2 Vr3 O1 O2 O3 O4 Vry O1 Vr O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 Vrx Vr1 Vr2 Vr3 O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 2
Vr Vrx Vr1 Vr2 Vr3 Vry O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 PROC REPORT Proc Report llows for greter flexiility in reporting results thn Proc Print. Additionlly, the syntx is similr to tht used for Proc Print, ut does require dditionl definitions to set line style, font, type fce, nd color scheme. Generlly, style sheet will set ech of those prmeters, ut use of the define sttement cn override individul prmeters. Columns re defined with the use of the column sttement rther thn the id sttement, ut dt sets my e still divided y clss nd y sttements. Agin, using the simple exmple provided previously to expnd the level of sophistiction: ods pth work.templte(updte) sshelp.tmplmst(red) lirry.templt(red); ods html file = pthnme ; style = stylesheetnme; title New dt sheet ; Proc Report dt = two_set; column vr4 vr5 vr6; y vrc vrd; clss vrx1 vry1; define vr4/ ctegory style(column)=[font weight=old foreground=cx01541c ckground=cxedf2ed fontsize=3]; define vr5 / (no.) ; The inclusion of the style cluse for vr1 forces the individul hndling for tht column to e different thn ll other columns defined y the column sttement. However, it produces nicely formtted tle where the first column is different font nd color thn the remining columns, which is desirle when the first column is not dt ut reporting ctegory such s stte or yer. It ppers identicl to the output produced y the Proc Print commnd. (tle 2) Tle 2. Simple Proc Report output using predefined style sheet nd columnr modifictions. Vrc Vrx1 Vr4 Vr5 Vr6 O1 O2 O3 O1 O2 O3 O1 O2 O3 3
Vrc Vrx1 Vr4 Vr5 Vr6 O4 Vry1 O1 Vrd O2 O3 O4 O4 O1 O2 O3 O4 O4 O1 O2 O3 O4 Vrx1 Vr4 Vr5 Vr6 O1 O2 O3 O4 Vry1 O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 O1 O2 O3 O4 DIFFERENCE With Proc Print, the style sheet defined is used in whole nd column 1 is defined s title column rther thn dt column with the use of the id sttement. The id sttement is not ville for use in Proc Report; insted the column sttement defines individul columns. Becuse Proc Report llows for specil hndling nd override of the style sheet prmeters, individul columns re hndled s pieces of the whole nd style sheet prmeters re only pplied where prmeters re not redefined. In 4
prticulr, column 1 is no longer defined s title column, insted it ecomes strictly dt reporting nd is hndled s such. The formtting of the column ecomes dt oriented nd must e ltered on column to column sis within Proc Report, s illustrted in the code ove. CONCLUSION In generl, Proc Report is more mngele for producing clen, concise output reports for specific udiences. However, in using ODS to pulish the reports, specil cre must e tken to ensure correct coding for columnr formtting. Use of y nd clss sttements with Proc Report ssists in mking the formtting esier, ut it is not fil proof. When outputting simple report with miniml formtting requirements, Proc Print with n id sttement is n esier nd more concise progrmming tool, ut it hs mny limittions in wht cn e done to improve formtting. ACKNOWLEDGMENTS I would like to thnk George Wiggns for ssisting with my progrmming skills nd nswering my endless progrmming questions s well s Dniel Null, Melvin Tooker, nd Suznne Hurd for technicl editing of this pper. RECOMMENDED READING SAS-L rchives re n excellent source of informtion out SAS progrmming nd tips nd tricks. An dditionl resource is the SAS online documenttion out ODS, Proc Print, nd Proc Report. The Little SAS Book : A Primer, Second Edition y Lor D. Delwiche nd Susn J. Slughter is lso terrific reference for those just lerning SAS. CONTACT INFORMATION Your comments nd questions re vlued nd encourged. Contct the uthor t: Lur L. M. Thornton Animl Scientist 10300 Bltimore Ave BARC-WEST, Bldg 005, Rm. 306 Beltsville, MD, 20705-2350 Phone: 301 504 8334 Fx: 301 504 8092 E-mil: Lur.Thornton@rs.usd.gov We: http://ipl.rsusd.gov/ SAS nd ll other SAS Institute Inc. product or service nmes re registered trdemrks or trdemrks of SAS Institute Inc. in the USA nd other countries. indictes USA registrtion. Other rnd nd product nmes re trdemrks of their respective compnies. 5