Breaking New Ground with SAS® 9.2 ODS Layout Enhancements Scott Huntley In the beginning … Inline formatting Columns= Startpage= ODS Features ODS Text Statements In-line formatting Nbspace Newline Proc REPORT data execs; 7 spaces length photo $20 name $32 title $80; input photo $20. / name $32. title $80.; datalines; c:\sgf2009\scott.jpg ~{nbspace 7} Scott Huntley President, Chief Executive Officer c:\sgf2009\dan.jpg ~{nbspace 7} Dan O'Connor Senior Vice President, Chief Information Officer title4 '~{style [just=left fontsize=14pt font_style=roman]Management Team}'; proc report data=execs nowd; column photo name title; compute name; call define(_col_, 'style', 'style=[just=left fontweight=bold color=cx494068 fontsize=14pt preimage="'||photo||'"]'); endcomp; compute title; call define(_col_, 'style', 'style=[fontsize=12pt]'); endcomp; ods pdf text='~{newline 2}'; ods pdf text='~{style [just=left fontsize=16pt fontweight=Bold]Board of Directors}'; proc report data=directors nowd; ODS Features Data Null In-line formatting data _null_; set class; by sex; file print; if age>= 15 then put '^{style [borderleftcolor=green borderrightcolor=red borderbottomcolor=blue bordertopcolor=orange]}' name age; else put name age; run; Columns= • Virtual pages • Split evenly Paneling ODS Graphics & columns ods pdf file='graph.pdf' columns=2; title "height and width set to 5"; ods graphics on / height=5in width=5in; proc sgplot data=stocks; ods graphics off; proc print data=sashelp.orsales(obs=15); Startpage ODS Features ODS Text Statements In-line formatting Columns= Newline function Nbspace function Startpage= Proc SGPLOT ods text = "~{style [color=blue just=center fontsize=24pt fontweight=bold]Quick Facts About Orion}"; ods text = "~{newline 2}"; ods text = "~{nbspace 20} ~{style [color=blue fontsize=16pt]~{unicode 00B7}Orion products are sold throughout the USA}"; ods text = "~{nbspace 20} ~{style [color=blue fontsize=16pt]~{unicode 00B7}Our nearly 5,000 employees help us operate 70 stores in 15 states}"; ods pdf columns=2 startpage=no; ods graphics on / height=3.75in width=3.75in noborder; proc sgplot; proc sgplot; ods pdf startpage=now; proc sgplot; ods text = "~{newline 2} ~{style [color=blue fontsize=16pt]All numbers are final as of January 01, 2004. Please contact Kevin Smith (CFO) if you see any discrepancies}"; ods graphics off; Device based Graphics & columns goptions reset=all hsize=4in vsize=4in border; ods pdf file='test.pdf' startpage=no; proc print; proc gchart; Foundation Benefits Appearance Placement Production Quality THE TRILOGY CONTINUES… EPISODE II: A NEW HOPE Absolute Layout Gridded Layout Ods layout start; Ods region; sas code…. Ods layout end; Not all ODS Destinations are created Equal Not all ODS Destinations support layout Page limitations How do I set the size? A dimension unit is a nonnegative number • cm centimeters • in inches • mm millimeters • pt a printer’s point ODS Layout Terminology Layout Container Region Container Dimension Unit Titles & Footnotes Proc Titles Page considerations Papersize Orientation Topmargin, Bottommargin, Leftmargin, Rightmargin DPI Absolute Layout Static Reports Placing information on a pre-printed form Creating a cover page Single page output Absolute Layout ods layout start [x=<dimension unit>] [y=<dimension unit>] [width=<dimension unit>] [height=<dimension unit>] ; ods region [x=<dimension unit>] [y=<dimension unit>] [width=<dimension unit>] [height=<dimension unit>] ; ods layout end; Using Absolute Layout to create a cover page ODS Features Custom style In-line formatting Absolute layout Using Absolute Layout to create a cover page Creating a custom style proc template; define style Styles.Orionbackground; parent =Styles.Printer; style body / background=cx494068; end; Run; Using Absolute Layout to create a cover page ods layout start; ods region y=2in ; ods text=“~{style [preimage=‘Image.jpg‘ color=cxbbb2e0 just=center font_size=72pt] Orion Star}"; Using Absolute Layout to create a cover page ods region y=3in x=3in; ods text="~{style [color=cxbbb2e0 font_size=28pt] Sports & Outdoors}"; Using Absolute Layout to create a cover page ods region y=5in; ods text="~{style [just=Center font_size=36pt color=cxbbb2e0] Executive Prospectus}"; Using Absolute Layout to create a cover page ods region y=7in; ods text="~{style [just=Center font_size=20pt color=cxbbb2e0] For years 1999 through 2002}"; ods layout end; Using Absolute Layout to create a static report ODS Features Custom style In-line formatting Absolute layout SAS/Graph Proc Report Using Absolute Layout to create a static report title "~{style [preimage=‘Header.jpg’ width=100pct background=cx494068 color=cxbbb2e0 font_size=32pt] Our Company }"; Using Absolute Layout to create a static report proc template; define style Styles.OrionCalloutBlock; parent =Styles.Printer; style LayoutRegion/ background=cxbbb2e0; end; run; ods pdf style=Styles.OrionCalloutBlock; < some more code > ods pdf style=Styles.Printer; Using Absolute Layout to create a static report ods region x=6in y=1.0625in width=2in height=1in; ods text=“Our Mission"; ods text=“To deliver … "; ods region x=6in y=2.1875in width=2in height=1in; ods text=“Our Vision"; ods text=“To transform … "; Using Absolute Layout to create a static report ods region y=5.5in width=4.75in height=4in; proc gchart data=sashelp.orsales; pie product_category / sumvar=profit value=none percent=outside slice=outside; run; Using Absolute Layout to create a static report ods region y=5.5in x=4.625in width=4.5in height=5in; proc report nowd data=sashelp.orsales style(header)={background=cx494068 color=cxbbb2e0}; columns product_category profit; define product_category / group; define profit /analysis sum format=dollar14.; run;quit; Gridded Layout Content is dynamic Horizontal or vertical alignment is necessary Multiple pages Just may be easier than using absolute Gridded Layout ods layout start < options >; ods region < options >; ods layout end; Anatomy of a Gridded Layout Column_widths Column_gutter Columns 3in 4in Anatomy of a Gridded Layout Row_Heights 2in 2in Row_gutter Rows 2.5in Gridded Layout Column 1 ods region [width=<dimension unit>] [height=<dimension unit>] [column=<n>] [column_span=<n> [row=<n>] [row_span=<n>]; ods layout end; Row 1 Row 2 Row 3 Column 2 Using Gridded Layout to create a dynamic report ODS Features In-line formatting Gridded layout ODS Report Writing Interface SAS/Graph Proc Report Using Gridded Layout to create a dynamic report 5.25in ods layout start columns=2 column_widths=(5.25in 2.5in); 2.5in Using Gridded Layout to create a dynamic report 5.25in ods region; ods text=“Our Creators”; ODS Report Writing Interface ods text=“Upcoming Events”; ODS Report Writing Interface ods text=“Recent News”; PROC Report 2.5in Using Gridded Layout to create a dynamic report 5.25in ods region; ods text=“Stock Information”; ODS Report Writing Interface PROC Sgplot ods text=”Featured Reports”; PROC Report ods text=“Annual Report…” ods text=“Corporate …”; 2.5in ODS Layout ods layout start columns=2 column_widths=(3.9in 3.9in); ODS Layout ods region; 1 2 3 Region 1 ods region; 1 2 3 ods text=“~{style SystemTitle [just=center color=cx494068] Average Profits for Each Product Line} ~{newline 1} ~{style SystemTitle [just=center color=cx494068] With 95% Confidence Limits}"; proc sgpanel data=test noautolegend; format prof dollar4.2; panelby product_line / layout=rowlattice novarname onepanel; rowaxis grid label="Profit in USD (in millions)"; colaxis fitpolicy=thin; vline quarter / response=prof stat=mean limitstat=clm group=product_line lineattrs=(pattern=solid); run; ods text="~{style [just=left width=100pct preimage='star.gif‘ color=cx494068] Is this a potential growth area?}“; Region 2 ods region; 1 2 3 Region 3 ods region column_span=2; 1 2 3 proc report nowd data=sashelp.orsales style(header)={background=cx494068 color=cxbbb2e0}; columns ('Product Line' product_line) year,(profit total_retail_price pmargin); define product_line / group ''; define year /across ''; define profit /analysis sum format=dollar14. ''; define total_retail_price / analysis noprint; define pmargin / computed format=percent6.1 ''; compute pmargin; _C4_ = _C2_ / (_C3_ - _C2_); _C7_ = _C5_ / (_C6_ - _C5_); _C10_ = _C8_ / (_C9_ - _C8_); _C13_ = _C11_ / (_C12_ - _C11_); endcomp; rbreak after / summarize; compute after; product_line = "Total"; endcomp; run;quit; Conclusion Startpage Columns= Text= In-line Formatting Absolute Layout Gridded Layout