Using the Output Delivery System

Download Report

Transcript Using the Output Delivery System

Using the Output Delivery System

October 22, 2004 Presentation to: The Toronto Area SAS Society ©Dofasco Inc., 2004 All rights reserved 1

Agenda

 Introduction  Book Review  CD Book Review  Some examples using ODS  Summary © Dofasco Inc. 2004 All rights reserved October 22, 2004 2

Introduction

 Book Review: Quick Results with the Output Delivery System, Sunil Gupta, © 2003, SAS Institute Inc.

 CD Book Review: Instant ODS, Bernadette Johnson, © 2003, SAS Institute Inc.

 Examples: Using ODS in some practical situations.

© Dofasco Inc. 2004 All rights reserved October 22, 2004 3

Quick Results with the Output Delivery System

 Beginner Level  About 100 pages (just the right length)  Well written  Clear Examples  Logical Progression © Dofasco Inc. 2004 All rights reserved October 22, 2004 4

Basic ODS Syntax

ODS TRACE

on /

;

ODS

destination

;

ODS OUTPUT

output-object-SAS-Data-Set-name

; ODS SELECT list ;

----- your program ------

ODS CLOSE ;

ODS TRACE

off; © Dofasco Inc. 2004 All rights reserved October 22, 2004 5

Destinations

 What format do you want your report in?

 HTML – web pages  PDF – acrobat reader  RTF- document format  Printer formats- PRINTER, PS, PCL  LISTING- traditional SAS output  MAIL- email

* not in book

ODS

destination

;

(Remember to match the extension to the destination)

© Dofasco Inc. 2004 All rights reserved October 22, 2004 6

Objects

 Blocks of output created by SAS procedures.

 Univariate:  Moments  BasicMeasures  TestsForLocation  Quantiles  ExtremeObs  ODS

SELECT /EXCLUDE

list

; © Dofasco Inc. 2004 All rights reserved October 22, 2004 7

© Dofasco Inc. 2004 All rights reserved

Inserting Graphs

Note: We are using a SAS Sample Data Set found in SASHELP     

filename odsout 'h:\Sas'; filename grafout 'h:\Sas'; goptions reset=all device=html; ODS HTML path=odsout gpath=grafout body="Test.htm"; options ps=55 ls=80 nodate nonumber;

  

title 'Steel Export Levels'; axis1 label=(a=-90 'Millions of Tons Exported'); symbol1 v=none i=join l=1 w=3;

  

proc gchart data=sashelp.steel; vbar date/discrete freq=steel raxis=axis1; run;

  

proc gplot data=sashelp.steel; plot steel*date/ vaxis=axis1; run;

 

ODS HTML Close; run;

October 22, 2004 8

Inserting Graphs

BASE HTML FILE

© Dofasco Inc. 2004 All rights reserved

INDEX FILE VARIOUS GRAPHS

October 22, 2004 9

© Dofasco Inc. 2004 All rights reserved

Viewing HTML Output

October 22, 2004 10

Instant ODS- Using Styles

 50 pre-packaged styles in HTML, PDF and RTF format.  Step 1: Check the system requirements  Step 2: Save the ODS library to a hard disk  Step 3: Select a style  Step 4: Insert your code into the basic ODS code provided  Step 5: Run program and enjoy results.

© Dofasco Inc. 2004 All rights reserved October 22, 2004 11

Instant ODS- Using Styles

 Some notes:  Match the code to the style carefully  When you use the code provided open in Notepad first (code_files folder on CD) and copy and paste into the editor  Print the welcome.pdf file  The time savings is great for the price!

© Dofasco Inc. 2004 All rights reserved October 22, 2004 12

© Dofasco Inc. 2004 All rights reserved 

An Instant ODS Example

Program:

ODS PATH

(PREPEND) demo.ODS(READ); 

GOPTIONS

HSIZE=

7

IN VSIZE=

5

IN; *size graphs 2.5in by 3.5in;     

ODS MARKUP TAGSET

=web_graph_1

FRAME

='h:\sas\demo\html-frame-tassdemo2.htm'

BODY

='h:\sas\demo\html-body-tassdemo2.htm'

CONTENTS

='h:\sas\demo\html-table-contents-tassdemo2.htm'

GPATH

='h:\sas\demo' (URL=NONE)

;

       

goptions

cback=cream;

title

f=zapfb h=

1.75

'Steel Exports in Millions of Tons';

symbol1

i=join l=

1

w=

4

v=none c=white;

axis1

label=(a=

90

f=zapfb h=

1.5

'Millions of Tons');

axis2

label=(f=zapfb h=

1.5

'Year' );

proc gplot

data=sashelp.steel;

plot

steel*date/haxis=axis2 vaxis=axis1 cframe=cream;

run

;  

ODS MARKUP CLOSE

;

Run

; October 22, 2004 13

ODS Output

© Dofasco Inc. 2004 All rights reserved October 22, 2004 14

Do-it-yourself Example

 Step 1: Set up a new style template  Program (Sets up a place to keep the style):       libname demo 'h:\sas\demo'; ods path demo.mytemp(update) sashelp.tmplmst(read); ODS PATH SHOW ;

proc template

; edit styles.default as styles.sc; style data from cell /background=vligb; style header from headersandfooters background=vligb;  © Dofasco Inc. 2004 All rights reserved October 22, 2004 15

Do-it-yourself Example

Program cont’d (General Colors and Styles):           style table from output / background=black borderwidth=

1

tagattr='align="left"'; style color_list / 'bgA' = ligb 'fgA2' = black 'fgA1'= black 'fga'= black; style colors / 'contitlefg'=color_list('fgA2') 'confolderfg'=color_list('fgA2'); style fonts / 'headingFont' = ("Arial, Helvetica, Helv",

1

, demi_bold) 'docFont' = ("Arial, Helvetica, Helv",

1

,demi_bold) 'titlefont' = ("Arial, Helvetica, Helv",

1

,bold);  © Dofasco Inc. 2004 All rights reserved October 22, 2004 16

Do-it-yourself Example

 Program cont’d (Table of Contents):      style contenttitle from indextitle /font=(arial,

3

,bold);  (Content Title) style contentproclabel from contentprocname /font=(arial,

2

);  (Label replacing the procedure) style contentprocname from indexprocname /font=(arial,

2

);  (The Procedure Name) style Bycontentfolder from Bycontentfolder /font=(arial,

2

);  (The by-variable info) style contentitem from indexitem /font=(arial,

2

);  (The item is the list) © Dofasco Inc. 2004 All rights reserved October 22, 2004 17

Do-it-yourself Example

Program cont’d (Table of Contents cont’d…):      style contentProcname from Indexprocname /bullet=none; style ByContentFolder from ContentFolder /Bullet = NONE ListEntryAnchor = yes PreHtml = _undef_ PostHtml = _undef_;       Style ContentItem from IndexItem /Bullet = NONE ListEntryAnchor = yes PreHtml = _undef_ PostHtml = _undef_ pretext="

" posttext="
"; © Dofasco Inc. 2004 All rights reserved October 22, 2004 18

Do-it-yourself Example

 Program cont’d (Table of Contents cont’d…):       Style ContentTitle from IndexTitle / PRETEXT='MECHANICAL PROPERTIES BREAKDOWN FOR 2003- ALL TESTS'; style contents from documents / background=vligb; style table from output / outputwidth=

10

%; end; 

run

; © Dofasco Inc. 2004 All rights reserved October 22, 2004 19

 The Log:

Do-it-yourself Example

© Dofasco Inc. 2004 All rights reserved October 22, 2004 20

Do-it-yourself Example

  Using the style: The program:   libname sasdata 'h:\sas\demo';

proc template

;       define style new; parent=styles.sc; *Changing Title name of the table of contents; replace ContentTitle from IndexTitle / PRETEXT='2003 Summary-By Grade Group' font=(arial,

3

,bold);   END;

RUN

; © Dofasco Inc. 2004 All rights reserved October 22, 2004 21

Do-it-yourself Example

        The Program cont’d: options nocenter; filename odsout 'h:\sas\demo\'; ods listing close; ods html path=odsout contents="TassDemo_Contents.html

frame="TassDemo_Frame.html" body="TassDemo_Body.html“ newfile=output style=new;      ODS PROCLABEL 'BY GRADE GROUP'; options pageno=

1

device=win; title1 'MECHANICAL PROPERTIES 2003 - Jan to Dec' ; TITLE2 ; FOOTNOTE1 'Note: Includes all test results'; © Dofasco Inc. 2004 All rights reserved October 22, 2004 22

               

Do-it-yourself Example

The Program cont’d:

proc tabulate

data=demo.test2 contents=''; class GradeGrp GradeNo StdCode DirectCd DispCd TempNo TemperCd ThickRange; var Yield TensileA ElongB Mech1020 ; keylabel mean='Avg'; label DispCd= 'Dispo'; table GradeGrp=“", all GradeNo='GRADE'* ThickRange='THICKNESS'* TempNo='TEMP'* TemperCD='CW'* DirectCd='DIR'* StdCode='STDC'* (all DispCd), Yield='YIELD'*(n*f=

4.0

mean*f=

5.1

std*f=

4.1

min*f=

5.1

max*f=

5.1

) TensileA='TENSILE'*(mean*f=

5.1

std*f=

4.1

min*f=

5.1

max*f=

5.1

) ElongB='ELONGATION'*(mean*f=

5.1

std*f=

4.1

min*f=

5.1

max*f=

5.1

) Mech1020='MECHVAL'*(mean*f=

5.3

std*f=

5.3

min*f=

5.3

max*f=

5.3

) /condense misstext='-' contents=‘ ' ;

run

; ods html close; ods listing; © Dofasco Inc. 2004 All rights reserved October 22, 2004 23

Do-it-yourself Example

 The Output: © Dofasco Inc. 2004 All rights reserved October 22, 2004 24

© Dofasco Inc. 2004 All rights reserved

Do-it-yourself Example

October 22, 2004 25

Instant ODS Example

 The Output using an ODS template: © Dofasco Inc. 2004 All rights reserved October 22, 2004 26

© Dofasco Inc. 2004 All rights reserved

Instant ODS Example

October 22, 2004 27

Summary

 Quick Results using the Output Delivery System  Instant ODS  Do-it-yourself Example  Instant ODS Example © Dofasco Inc. 2004 All rights reserved October 22, 2004 28

Questions?

Contact information: Lesley Harschnitz [email protected]

Sandra Cunningham [email protected]

© Dofasco Inc. 2004 All rights reserved October 22, 2004 29