ODS BORTOM DET UPPENBARA PROGRAMMERA SNYGGA RAPPORTER! [email protected]

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

DAGORDNING •

Vad är 

ODS LAYOUT  ODS Report Writing Interface (RWI) •

Djupdykning i  

Gridded Layout Absolute Layout

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

VAD ÄR ODS LAYOUT? •

• •

En uppsättning nya globala ODS-statements (ODS LAYOUT & ODS REGION) Visar ODS output-objekt (output från SAS-proccar samt datasteg), plus text och bilder Arrangerar output-objekten dynamiskt i rutnät eller pixel-perfect dvs.  

Gridded Layout Absolute Layout

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

VAD ÄR ODS REPORT WRITING INTERFACE (RWI)?

“The ODS Report Writing Interface could be described as the DATA step’s PUT statement on steroids” http://support.sas.com/resources/papers/proceedings14/SAS330-2014.pdf

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

VAD ÄR ODS REPORT WRITING INTERFACE (RWI)? •

• •

ODSOUT Object och ett antal metoder i datasteget Läser ett dataset precis som vanligt och petar ut det som skall visas, plus textrutor och bilder Arrangerar detta i formen av:   

Gridded Layout Absolute Layout Table

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT (LAYOUT OCH RWI) • •

• • • •

Två-dimensionellt rutnät, som i en tabell (regioner bestående av kolumner och rader) Innehållet i en region justeras dynamiskt i storlek/position Rutnätet populeras rad för rad och kolumn för kolumn Kan spänna över flera sidor Kolumner och rader kan slås samman (SPAN) Stöder HTML & PRINTER-destinationerna (t.ex PDF)

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT (FORTS.) ods layout gridded columns=2 …; ods region; … contents … ods region; … contents … ods region; … contents … ods region row_span=2; … contents … ods region; … contents … ods region column_span=2; … contents … ods layout end;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Region Container

Layout Container

GRIDDED LAYOUT MED ODS LAYOUT ods pdf file="pacificGridded.pdf" notoc nogtitle; ods layout gridded columns=2 column_gutter=0in advance=bygroup; ods region height=1in column_span=2 style={background=&backBlue. just=right}; ods text="^S={background=&backBlue. foreground=white font_size=50pt}ACME"; ods text="^S={background=&backBlue. foreground=white font_size=10pt}Sales Report Pacific Region"; ods region; goptions … hsize=4in vsize=2.5in …; axis, pattern & legend statements…; proc gchart data=acmeSorted; …gchart statements…; run; quit; ods layout end; ods pdf close;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT MED ODS LAYOUT (FORTS.) ods pdf file="pacificGridded.pdf" notoc nogtitle;

ods layout gridded columns=2 column_gutter=0in advance=bygroup; ods region height=1in column_span=2 style={background=&backBlue. just=right}; ods text="^S={background=&backBlue. foreground=white font_size=50pt}ACME"; ods text="^S={background=&backBlue. foreground=white font_size=10pt}Sales Report Pacific Region"; ods region; goptions … hsize=4in vsize=2.5in …; axis, pattern & legend statements…; proc gchart data=acmeSorted; …gchart statements…; run; quit;

ods layout end; ods pdf close;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT MED ODS LAYOUT (FORTS.) ods pdf file="pacificGridded.pdf" notoc nogtitle; ods layout gridded columns=2 column_gutter=0in advance=bygroup; ods region height=1in column_span=2 style={background=&backBlue. just=right}; ods text="^S={background=&backBlue. foreground=white font_size=50pt}ACME"; ods text="^S={background=&backBlue. foreground=white font_size=10pt}Sales Report

ods region; goptions …hsize=4in vsize=2.5in; axis, pattern & legend statements; proc gchart data=acmeSorted; …gchart statements…; by state propGroup; run; quit; ods layout end; ods pdf close;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Pacific Region";

Graph2:1:State State==Alaska Alaska Graph PropertyGroup Group==Residential Commercial Property

Graph 4: 3: State State == California California Graph Property Group Group == Residential Commercial Property

GRIDDED LAYOUT MED ODS LAYOUT (FORTS.)

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT MED RWI data _NULL_; set acmeSorted (where=(year=2013)) end=done; by state propGroup; if _N_= 1 then do; dcl odsout DL650(); DL650.layout_gridded(width: “21cm"); DL650.region(style_attr: "background=&backBlue. just=right"); DL650.format_text(data: "ACME", just: "right", style_attr: "background=&backBlue. foreground=white font_size=50pt"); DL650.format_text(data: "Pacific Region", just: "right", style_attr: "background=&backBlue. foreground=white font_size=10pt"); DL650.region(); DL650.format_text(data: "Total Numbers of Units Sold by Property Type and State for the Year " || strip(year) || ", separated by Commercial/ Residential."); DL650.layout_end(); DL650.layout_gridded(columns: 3); end; if first.state and first.propGroup then do; DL650.region(); DL650.format_text(data: state, style_elem: "SystemTitle"); end; if first.propGroup then do; DL650.region(style_attr: "just=left"); DL650.format_text(data: propGroup, style_elem: "SystemTitle"); DL650.format_text(data: ""); end; DL650.format_text(data: strip(propType) || ": ", inline_attr: "font_weight=bold", data: soldUnits, format: "comma10."); if done then do; DL650.layout_end(); end; run;

ODS RWI-programstruktur

Deklarera

declare odsout vad_som_helst();

Metodanrop

vad_som_helst.( < method parameters > );

Avsluta/stänga destinationen vad_som_helst.layout_end();

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT WITH RWI (FORTS.) data _NULL_; set acmeSorted (where=(year=2013)) end=done; by state propGroup; if _N_=1 then do;

dcl odsout DL650(); DL650.layout_gridded(width: “21cm"); DL650.region(style_attr: "background=&backBlue. just=right"); DL650.format_text(data: "ACME", just: "right", style_attr: “…"); DL650.format_text(data: "Pacific Region", just: "right", style_attr: “…");

DL650.region(); DL650.format_text(data: "Total Numbers …" || strip(year) || ", separated ..."); DL650.layout_end(); DL650.layout_gridded(columns: 3); end; C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

if first.state and first.propGroup then do; DL650.region(); DL650.format_text(data: State, style_elem: "SystemTitle"); end; if first.propGroup then do; DL650.region(style_attr: "just=left"); DL650.format_text(data: propGroup, style_elem: "SystemTitle"); DL650.format_text(data: ""); /* En tom rad…*/ end; DL650.format_text(data: strip(propType) || ": ", inline_attr: "font_weight=bold", data: soldUnits, format: "comma10.");

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

if first.state and first.propGroup then do; DL650.region(); DL650.format_text(data: state, style_elem: "SystemTitle"); end; if first.propGroup then do; DL650.region(style_attr: "just=left"); DL650.format_text(data: propGroup, style_elem: "SystemTitle"); DL650.format_text(data: ""); /* En tom rad…*/ end; DL650.format_text(data: strip(propType) || ": ", inline_attr: "font_weight=bold", data: soldUnits, format: "comma10.");

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

if first.state and first.propGroup then do; DL650.region(); DL650.format_text(data: state, style_elem: "SystemTitle"); end; if first.propGroup then do; DL650.region(style_attr: "just=left"); DL650.format_text(data: propGroup, style_elem: "SystemTitle"); DL650.format_text(data: ""); /* En tom rad…*/ end; DL650.format_text(data: strip(propType) || ": ", inline_attr: "font_weight=bold", data: soldUnits, format: "comma10.");

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

GRIDDED LAYOUT WITH RWI (FORTS.)

if done then do; DL650.layout_end(); end; run;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT

• • • • •

Regionerna kan nu överlappa (Tidigare låg de sida vid sida) Regionerna defineras oftast med X/Y-koordinater, samt bredd och höjd Ordningen som regionerna definieras i, är den ordning de kommer ut Begränsat till 1 sida – resultatet kan ej spänna över flera sidor Stöder endast PRINTER-destinationen (pdf m.fl…)

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT (FORTS.)

Layout Container

X=0 Y=0

ods layout absolute; ods region x=0in y=0in width=5in height=3in … contents … ods region x=3in y=1in width=4in height=5in; … contents … ods region x=2in y=8in; … contents … ods region; … contents …

ods layout end;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Region Container

ABSOLUTE LAYOUT MED ODS LAYOUT

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED ODS LAYOUT (FORTS.) ods pdf file="pacificAbsolute.pdf" notoc;

ods layout absolute; ods region height=1in style={background=&backBlue.}; ods text=" ";

ods region x=5.5in width=2.5in height=1in style={background=&backBlue.}; ods text="^S={background=&backBlue. foreground=white font_size=50pt}ACME"; ods text="^S={background=&backBlue. foreground=white font_size=10pt}Sales Report

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Pacific Region";

ABSOLUTE LAYOUT MED ODS LAYOUT (FORTS.) ods region y=1.25in width=4.75in height=1.25in; ods text="^S={font_size=8pt}Commercial property…"; ods text=" "; ods text="^S={font_size=8pt}Buoyed by steadying…"; ods region y=2.75in width=4.75in height=2.75in; …code to generate graph… ods region x=5in y=1.25in width=3in height=0.18in style={background=&backBlue.}; ods text="^S={just=center background=&backBlue. …}…"; ods region x=5in y=1.6in width=3in; …code to display image…

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED ODS LAYOUT (FORTS.) ods region y=5.5in height=2.5in width=3in; …code to generate pie chart… ods region y=5.5in width=8in height=0.18in style={background=&backBlue.}; ods text="^S={just=center background=&backBlue. …} …"; ods region x=3.5in y=5.8in height=2.2in; …code to generate table structure…

…more regions and more content… ods layout end; ods pdf close

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED ODS LAYOUT (FORTS.)

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED RWI

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED RWI (FORTS.) ods pdf file="propDetails.pdf" notoc;

data _NULL_; set acmeHouses end=done; if _N_ = 1 then do; dcl odsout DL650(); end;

DL650.layout_absolute(); DL650.region(width: "8in",height: "1in", style_attr: "background=&backBlue."); DL650.format_text(data: "", style_attr: "background=&backBlue."); DL650.region(x: ".5in", y: ".2in", width: "3in", height: "1in"); DL650.format_text(data: name, style_attr: "…");

DL650.format_text(data: street1, style_attr: "…");

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED RWI (FORTS.) DL650.region(x: "5.5in", width: "2in", height: "1in"); DL650.format_text(data: "ACME", just: "right", style_attr: “…"); DL650.region(x: "5.5in", y: ".7in", width: "2in", height: ".5in"); DL650.format_text(data: "Pacific Region", just: "right", style_attr: “…"); DL650.region(y: "1.25in", width: "4in", height: "3in"); DL650.image(file: "&imageLoc." || strip(listNum) || ".jpg"); DL650.region(x: "4in", y: "1.25in", width: "4in", height: "3in"); DL650.format_text(data: "General Information", style_attr: “…");

DL650.format_text(data: ""); DL650.format_text(data: desc); …code to generate table structure…

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED RWI (FORTS.) DL650.region(y: "4.5in", width: "8in", height: "3in"); DL650.format_text(data: "Building Features", style_attr: " … "); DL650.format_text(data: ""); …code to generate table structure… …more regions and more content… DL650.layout_end();;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

ABSOLUTE LAYOUT MED RWI (FORTS.)

if not done then do; DL650.page(); end; run;

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

SUMMERING •

Vad är 

ODS LAYOUT  ODS Report Writing Interface (RWI) • •

Gridded Layout Absolute Layout

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

DOKUMENTATION OCH LÄNKAR… •

ODS på support… http://support.sas.com/software/products/base 

SAS® 9.4 Output Delivery System: User's Guide »



SAS® 9.4 Output Delivery System: Advanced Topics »



• •

Chapter 5: Dictionary of ODS Language Statements Part 3: Report Writing Interface (Chapters 10, 11 & 12)

Step-By-Step Programming with Base SAS® 9.4

ODS LAYOUT & RWI Tip Sheets http://support.sas.com/rnd/base/ods/ Mycket, mycket, mer…

C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

FRÅGOR! C op yr i g h t © 2 0 1 5 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .