An Insider’s Guide to ODS LAYOUT Using SAS®...

34
An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 Bari Lawhorn

Transcript of An Insider’s Guide to ODS LAYOUT Using SAS®...

Page 1: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 Bari Lawhorn

Page 2: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

2

Add some color and style Proc TEMPLATE

style body from body /backgroundcolor=light blue;

Style={background = color}

Layout or Region statement

ods layout start height=9.5in width=7in style={background = yellow};

ods region style={background = lightpink};

Page 3: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

3

Page

Layout

Region

Page 4: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

4

ods layout start height=9.5in width=7in style={background = yellow};

ods region x=1in y=1in height=3in width=5in style={background = lightpink};

X = 1 inch

Y = 1 inch 5 inches

Page 5: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

5

Know what’s in your Output Titles/Footnotes

Non-Layout output objects

Margins

ods layout start width=11in height=8.5in;WARNING: WIDTH exceeds available space for PDF destination. This option will be ignored.

Page 6: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

6

Give me the biggest available space Options statement

options leftmargin=0in rightmargin=0in topmargin=0in bottommargin=0in;

Watch out … Margins are reset to 0.25 inches

Correct (reasonable) options statementoptions leftmargin=.001in rightmargin=.001in

topmargin=.001in bottommargin=.001in;

Page 7: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

7

Give me the biggest available space

Correct (reasonable) options statement:

options leftmargin=.001in rightmargin=.001in

topmargin=.001in bottommargin=.001in;

Modified ODS LAYOUT dimensions:

ods layout start width=10.75in height=8.25in;

Page 8: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

8

Units of Measure Percentages

ods region x=5pct y=5pct height=20pct width=35pct style={background = lightpink};

Inchesods region x=4in y=.25in height=4in width=2instyle={background = green};

Page 9: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

9

Page 10: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

10

Tables: Uneven Widths Same PROC REPORT… Same region size

ods region x=1in y=0.1in height=1.75in width=5in;

PROC REPORT data= sashelp.cars(obs=5);column make model type origin drivetrain MSRP invoice;run;

ods region x=1in y=2in height=1.75in width=5in;

Page 11: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

11

Tables: Uneven Widths

OBS 1 - 5

OBS 6 - 10

Page 12: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

12

Tables: Uneven Widths

Page 13: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

13

Tables: Even Widths Use style attribute WIDTH on Report

PROC REPORT data = sashelp.cars(obs=5) style(report)=[width=5in];

Specify style attribute CELLWIDTH on columns

PROC REPORT data = sashelp.cars(firstobs=5 obs=10);column make model type origin drivetrain MSRP invoice;define make / STYLE(column)=[cellwidth=0.5in];define model / STYLE(column)=[cellwidth=1.5in];

Page 14: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

14

Even Widths

Page 15: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

15

What’s new in 9.4 Page Breaks

ods layout end;

ods startpage = now;

ods layout start;

Page 16: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

16

What’s new in 9.4 Startpage = Never Stay Positive … no negative numbers

ods region x=-4.0in y=5in; WARNING: Invalid X specified for PDF destination. This option will be ignored.

Page 17: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

17

Log MessagesNOTE: Writing HTML Body file: sashtml.htm

WARNING: Absolute layout is not supported for HTML destination. Layout will be ignored.

ods html close;

Page 18: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

18

Log MessagesERROR: Absolute layout is supported only for ODS PRINTER. Non-COLUMN/ROW LAYOUT requests will be ignored for other destinations.

ods _all_ close;

Page 19: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

19

Graphs inside ODS Layoutods graphics / reset;

ods pdf file='test.pdf' nogtitle nogfoot style=color;

ods layout start width=8in height=9in style={background=yellow};

ods region style={background=lightpink};

proc sgplot data=sashelp.class;

vbar age;

run;

Page 20: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

20

Page 21: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

21

Graphs Sizing No size set … Graph Template

Region size … Controls spaceods region height=4in width=4in style={background=lightpink};proc sgplot data=sashelp.class;vbar age;run;

ods region height=3in width=3in style={background=lightgreen};proc sgplot data=sashelp.class;vbar sex;run;

Page 22: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

22

3in x 3in

4in x 4in

Page 23: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

23

Regions & Graphs Prevent Overlap … (0,0)

Graphs fit into Regions

Aspect Ratio

Page 24: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

24

ODS GRAPHICS: take controlods graphics / reset height=4in width=4in;

ods layout start width=8in height=9in style={background=yellow};

ods region style={background=lightpink};

proc sgplot data=sashelp.class;

vbar age; run;

ods graphics / reset height=3in width=3in;

ods region y=5in style={background=lightgreen};

proc sgplot data=sashelp.class;

vbar sex; run;

Page 25: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

25

5in

4in

3 in

Page 26: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

26

Titles and Footnotes – SAS 9.4m3

Page 27: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

27

Titles and Footnotes – SAS 9.4m3 All Titles and Footnotes are supported

title2 'Title for the region w/Print & Report';footnote2 'Footnote for the region w/ Print & Report';ods region style={background=lightgreen};

proc print data=sashelp.class(obs=3);footnote2 'Proc Print footnote'; run;proc report data=sashelp.class(obs=5);title2 'Proc Report title';footnote2 'Proc Report footnote';run;

Page 28: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

28

ODS Layout vs Columns= Layout

PDF Columns= ods pdf file="columns_text.pdf" notoc columns=2 style=color;title "Columns test";

ods text="Lorem ipsum …";ods pdf startpage = now;

proc print data=sashelp.class(obs=3);run;

Page 29: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

29

Columns= Columns divide page

Startpage=now

4 in 4 in

Page 30: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

30

ODS Layout Columns Varying length Columns

ods pdf file="col_lay1.pdf" notoc style=color;title "Columns with Layout test";

ods layout start columns=2;ods region width=4.5in;

ods pdf text="Lorem ipsum …";

ods region width=3in ;proc print data=sashelp.class(obs=3);run;

Page 31: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

31

Layout columns User defined widths

4.5 in 3 in

Gutter ~.2 in

Regions with Gutters

Page 32: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

32

Layout Gutterods layout start columns=2 column_gutter=1.5in;

ods region width=3in style={background=lightpink};

ods region width=3in style={background=lightgreen};

3 in 3 inGutter 1.5 in

Page 33: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

33

Know before you go … Be an Adventurous Programmer

Accuracy is the Key

Always be Flexible

Page 34: An Insider’s Guide to ODS LAYOUT Using SAS® 9dasug.dartmouth.edu/wp-content/uploads/SGF15_Insider_LAYOUT.pdf · An Insider’s Guide to ODS LAYOUT Using SAS® 9.4 . ... column

34

Resources and Contacts ODS LAYOUT tip sheets

http://support.sas.com/rnd/base/ods/

ODS and Base Reporting https://communities.sas.com/community/support-communities/ods_and_base_reporting

SAS Technical Supporthttp://support.sas.com/

ODS Development [email protected]