Professional Documents
Culture Documents
Presented By:
Andrew H. Karp
Sierra Information Services, Inc.
19229 Sonoma Highway #264 Sonoma, California 95476 USA 707 996 7380 SierraInfo @ AOL.COM http://www.SierraInformation.com
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 01 Mar 03
Agenda/Topics
How does the ODS work? Understanding and working with
Objects/Tables Destinations
Destinations
OUTPUT Destination: working with SAS data sets created by ODS CSV, RTF, HTML and PDF Destinations Modifying the appearance of your output
2
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
Set of tools to control the delivery of SAS-generated output Prior to Version 8 all Procedure-generated output was rendered as text and placed in the Output Window
Very little user control over content or display Often difficult to capture Procedure-generated output as SAS data sets Prior to Version 8, the Procedure generated the output
Output objects are sent by SAS to ODS destinations The destination determines how the output will be rendered
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
Dont spend lots of time making RTF, HTML or other types of ODSgenerated output until you are sure that your report/table/output is what you want it to look like Using the NOPRINT Option in a SAS Procedure disables the PROCs ability to send tables to the Output Delivery System
6
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
Data Set
Data Component
Analyses, tables, etc.
Adapted from The Complete Guide to the SAS Output Delivery System (SAS Institute, 2001), page 22
Output Object
8
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
Output Object
ODS Destinations
LISTING
RTF
HTML
CSV OUTPUT
9
Adapted from The Complete Guide to the SAS Output Delivery System (SAS Institute, 2001), page 22
title1 'ODS for Data Analysts & Statisticians'; title2 'Objects and Destinations'; title3 'Default PROC REG Output: Simple Regression Model';
quit;
10
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
RESULTS Window. By default, ODS has sent the output objects generated from the PROC REG output to the default LISTING (Output Window) Destination.
11
12
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
13
14
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
Procedure Documentation
All ODS-compliant Procedures have a list of tables in their documentation
15
ods proclabel = 'Ex 3: ODS TRACE ON/OFF'; proc reg data=sugi28.regressdata; model depvar = y1/r;
title3 'Residual Analysis with ODS TRACE ON/OFF';
quit;
16
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
17
18
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
ods proclabel = 'Ex 4: ODS TRACE ON/LISTING'; proc reg data=sugi28.regressdata; model depvar = y1/r; title3 'ODS TRACE ON/LISTING'; quit; ods trace off;
19
20
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
10
21
22
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
11
A (small) excerpt from the ODS Table Names segment of PROC REG documentation.
23
Output Objects are Sent by the ODS to Destinations The Default Destination is LISTING
The Output Window
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
12
25
Selecting Tables
* example 5: Selection Lists/Persistence;
ods proclabel = 'Ex 5B: Default Re-Set of Selection List'; proc reg data=sugi28.regressdata; model depvar = y2;
title3 'ODS Select Statement'; title4 'Persistence of Selection Lists'; quit;
26
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
13
Selecting Tables
By default, selection lists are re-set to ALL at the end of all (explicit or implicit) step boundaries.
27
Selecting Tables
* example 5: Selection Lists/Persistence; ods select fitstatistics; ods proclabel = 'Ex 5A: Selection Lists/Persistence'; proc reg data=sugi28.regressdata; model depvar=y1; title3 'ODS SELECT Statement';
quit;
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
14
Can be used/manipulated just like any other SAS data set created using other methods
Data Step Procedure Step
30
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
15
ods proclabel = 'EX6: Creating SAS Data Set from Output'; proc reg data=sugi28.regressdata; model depvar = y2; title3 'ODS Output Statement'; title4 'Creating SAS Data Sets from PROC Output'; quit; proc print data=sugi28.fit1; title3 'SAS Data Set Created from FITSTATISICS Object'; run; proc contents data=sugi28.fit1; title3 'Descriptor Portion Info for Data Set SUGI28.Fit1'; run;
31
In this example, a permanent SAS data set was created from the FITSTATISTICS Object and stored in the folder with SUGI28 as its LIBREF. Since the LISTING Destination is always open by default, running the Procedure steps on the previous page resulted in having the ODS sent output to two Destinations: Listing (for all objects) and Output (for the Fitstatistics Object) 32
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
16
SAS VIEWTABLE for data set SUGI28.FIT1, created by the ODS when the PROC REG-generated data component was rendered as a SAS data set using the OUTPUT Destination.
33
The SAS System SAS Data Set Created from FITSTATISICS Object Obs Model Dependent Label1 1 MODEL1 DEPVAR Root MSE 2 MODEL1 DEPVAR Dependent Mean 3 MODEL1 DEPVAR Coeff Var c Obs nValue1 Label2 Value2 1 1038.936147 R-Square 0.7150 2 2109.386400 Adj R-Sq 0.7091 3 49.253003
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
17
3 8 0 120 0
Alphabetic List of Variables and # Variable Type Len 2 Dependent Char 32 3 Label1 Char 14 6 Label2 Char 8 1 Model Char 32 4 cValue1 Char 11 7 cValue2 Char 7 5 nValue1 Num 8 8 nValue2 Num 8
Attributes Format
35
or
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
18
37
ods proclabel = 'Ex 7: Closing the LISTING Destination'; ods output fitstatistics = sugi28.fit2; ods output parameterestimates = sugi28.est1;
proc reg data=sugi28.regressdata; model depvar = y1; quit;
In this example, the LISTING Destination is CLOSED while the OUTPUT Destinations are open ONLY for the FITSTATISTICS and PARAMETERESTIMATES Objects. After the explicit Step Boundary terminating the PROC REG task, the LISTING destination is re-set to ON so that output from subsequent SAS procedure steps will be displayed in the Output Window. 38
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
19
Since the LISTING Destination was CLOSED, and the OUTPUT Destinations were opened only for the FITSTATISTICS and PARAMETERESTIMATES Objects, the Results Window shows that we have two SAS data sets, and no other output, generated from the PROC REG task in Example 7.
39
Comma Separated Values Portable Document File Hypertext Markup Language Rich Text Format
ODS Destinations
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
20
41
* ex 17: CSV Destination; options symbolgen; ods listing close; ods select parameterestimates; ods CSV file = "&path\parameters.csv"; proc reg data=sugi28.regressdata; model depvar = &best; title2 'Optimal Subset Selection with ODS'; quit; ods csv close; ods listing;
42
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
21
77 78
43
44
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
22
45
46
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
23
47
48
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
24
49
50
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
25
51
An important note from the SAS Tech Support Web Site regarding problems using the BODYTITLE option with the RTF destination. It will only work if the DATE and NUMBER System Options are in effect.
52
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
26
53
54
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
27
Specifying a STYLE
Here is an example of specifying a STYLE when generating an RTF file
options date number; ods listing close; ods rtf file = 'bestsubsets2.rtf' BODYTITLE style=d3d; proc print data=sbc label obs='Model'; title1 'SAS ODS for Data Analysts and Statisticians'; title2 'Working with Output Data Sets'; title3 'Optimal Subset Selection: Logistic Regression Model'; title4 'Using the D3D Style'; run; ods rtf close; ods listing;
55
Specifying a STYLE
56
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
28
Specifying a STYLE
57
Specifying a STYLE
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
29
Understanding Styles
title1 'ODS for Data Analysts and Statisticians'; title2 'SAS-Supplied STYLES in Version 9';
run;
59
60
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
30
61
62
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
31
63
64
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
32
Example:
Use PROC CORR to generate correlation coefficients among several variables and output results to an HTML file Use PROC REG to create several linear regression models and output results to the same HTML file in which the PROC CORR output was sent.
65
66
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
33
67
68
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
34
69
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
35
71
72
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
36
Summary/Conclusions
73
ODS 201: Making Life Easier with the SAS Output Delivery System
Presented By:
Andrew H. Karp
Sierra Information Services, Inc.
19229 Sonoma Highway #264 Sonoma, California 95476 USA 707 996 7380 SierraInfo @ AOL.COM http://www.SierraInformation.com
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 01 Mar 03
74
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
37
75
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
38
77
run;
ods output fitstatistics = sugi28.model2; ods listing close; ods proclabel = 'Ex 9b: Respond=Risk Score'; proc logistic data=sugi28.predmodel descending; model respond = risk_score; run; Continued on next page ods listing;
78
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
39
The Results Window on the left shows the results of applying the PERSIST option in the ODS SELECT statement. Only the FITSTATISTICS Object is created by each PROC LOGISTIC task. Using ODS LISTING CLOSE/ODS LISTING for Example 9b further restricted the output to just a SAS data set.
80
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
40
PERSIST=PROC instructs SAS to keep the the selection or exclusion lists in effect after a procedure step boundary MATCH_ALL instructs SAS to create a new SAS data set for each object it creates
When only one data set is created, the data set name created is the one specified in the ODS OUTPUT statement. When multiple data sets are created, then SAS appends digits to the name of the data set given in the ODS OUTPUT statement
81
Steps:
Have ODS create a SAS data set containing the AIC for each of the five models. Use SAS data set options to shape each output data set so they contain just the observations/variables needed at subsequent points in the process
82
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
41
Once we know what the output data set looks like, write the ODS OUTPUT Statement so that
Only the desired observations/variables are output to the data sets
SAS data set options are applied to the output data sets
83
ods listing close; * close listing destination; ods select fitstatistics; * select fitstatistics table; ods output fitstatistics=fit_test; * run one model to see what we get; proc logistic data=predmodel descending; model respond=income; run; ods listing; * re-open listing destination; proc print data=fit_test;
title1 'ODS for Data Analysts and Statisticians'; title2 'Comparing Logistic Regression Models'; title3 'FITSTATISTICS Object as a SAS Data Set'; run;
84
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
42
Obs 1 2 3
85
What It Does
Output Destination remains open across multiple procedure step boundaries Create a new data set each time an Object is sent to the OUTPUT Destination AIC is the name of the first data set created, subsequent data sets are named AIC1, AIC2, etc. Restricts observations in output data set to those satisfying conditions in the WHERE clause Drops the automatically created variables _RUN_ and _PROC_ from each output data set 86
DROP
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
43
proc logistic data=predmodel descending; model respond=income; run; proc logistic data=predmodel descending; model respond=credit_card_balance; run; proc logistic data=predmodel descending; model respond=risk_score; run; proc logistic data=predmodel descending; model respond = length_of_residence; run; proc logistic data=predmodel descending; model respond = income credit_card_balance risk_score length_of_residence; run;
ods select all; * reset selection list; ods listing; * reset listing destination to ON;
87
88
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
44
89
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
45
91
92
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
46
by Territory;
model respond = income credit_card_balance risk_score length_of_residence; run; This Procedure Step will generate parameter estimates for three separate models, one for each value of the variable Territory. The ODS OUTPUT Statement will create three separate SAS data sets holding the parameter estimates. Their names are RESULTS, RESULTS1 and RESULTS2. A variable in the Macro Symbol Table (SASHELP.VMACRO) called MACROVAR, holds the names of the data sets. 93
94
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
47
options symbolgen;
The SYMBOLGEN SAS System option controls whether the results of macro symbol resolutions are written to the SASLOG. The shipped default option setting is NOSYMBOLGEN.
95
NOTE: There were 5 observations read from the data set WORK.RESULTS. NOTE: There were 5 observations read from the data set WORK.RESULTS1. NOTE: There were 5 observations read from the data set WORK.RESULTS2.
NOTE: DATA statement used (Total process time): real time 0.13 seconds cpu time 0.07 seconds
96
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
48
97
98
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
49
100
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
50
101
SAS Data Set created by ODS. Notice that variable label (Y1) is captured by the variable named Model and that variable Label2 stores the name of the statistic of interest (R-Square). Finally, variable Cvalue2 hold the computed value of R-Square (0.8895).
102
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
51
103
104
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
52
105
The statistics of interest were stacked in to one data set The stacked data set was then sorted in descending value of the R-square statistic, thus putting the best model at the top of the data set.
106
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
53
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
54
109
110
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
55
We can have the independent variables for the winning (statistically optimal model) output to a macro variable, and then used in a subsequent PROC REG task to generate parameter estimates and other measures of model performance for the optimal subset of independent variables.
111
data _null_; set allpossiblemodels(obs=1); call symput('best',varsinmodel); run; options symbolgen; ods output parameterestimates = bestsubset; proc reg data=sugi28.regressdata; model depvar = &best; title2 'Optimal Subset Selection with ODS'; quit;
112
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
56
NOTE: There were 1 observations read from the data set WORK.ALLPOSSIBLEMODELS. NOTE: DATA statement used (Total process time): real time 0.36 seconds cpu time 0.12 seconds 36 37 options symbolgen; 38 ods output parameterestimates = bestsubset; 39 proc reg data=sugi28.regressdata; 40 model depvar = &best; SYMBOLGEN: Macro variable BEST resolves to Y2 Y3 Y4 Y6 Y7 41 title2 'Optimal Subset Selection with ODS'; 42 quit;
113
Variable Intercept Y2 Y3 Y4 Y6 Y7
Label Intercept Indep Var Indep Var Indep Var Indep Var Indep Var 2 3 4 6 7
DF 1 1 1 1 1 1
114
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
57
Review
So far, weve seen some ODS capabilities:
Create/manage output objects
Selection of objects Persistence of selection lists across PROC or RUN groups
PERSIST=PROC or PERSIST = RUN MATCH_ALL MATCH_ALL=macrovar
Traffic Lighting
Traffic Lighting refers to process of displaying different colors to the values of variables based on some decision rule.
This process is very easy to implement in PROCs REPORT and TABULATE Example: using the regression analysis results data set, portray the value of the variable representing pvalue as:
Green if the p-value is less than .05 Blue if the p-value is between .05 and .10 Red if the p-value is greater than .10
116
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
58
Traffic Lighting
117
Traffic Lighting
This example of traffic lighting was created by:
Generating a format Applying the format and other ODS style definitions within PROC REPORT
proc format; value pvalf low - .0499999 = 'green' .05 - .0999999 = 'blue' .1 - high = 'red'; run;
118
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
59
Traffic Lighting
options nonumber nodate nocenter; ods listing close; ods pdf file = "&path\bestsubset.pdf" style=sasweb; proc report data=bestsubset split = '/' nowindows; column Variable DF Estimate StdErr tValue Probt Label ; define dependent/display 'Dependent/Variable' style(column)=[font_weight=bold]; define DF/display 'Degrees/of/Freedom'; define estimate/display 'Parameter/Estimate' style(column)=[font_weight=bold]; define stderr/display 'Standard/Error' ; define tvalue/display 'Test/Statistic';
119
Traffic Lighting
120
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
60
121
proc report data=bestsubset split = '/' nowindows; column Variable DF Estimate StdErr tValue Probt Label ; define dependent/display 'Dependent/Variable' style(column)=[font_weight=bold]; define DF/display 'Degrees/of/Freedom'; define estimate/display 'Parameter/Estimate' style(column)=[font_weight=bold]; define stderr/display 'Standard/Error' ; define tvalue/display 'Test/Statistic'; define probt/'P/Value' style(column)=[foreground=pvalf. font_weight=bold]; define label/'Variable/Label' style(column)=[fontweight=bold]; title1 'ODS for Data Analysts and Statisticians'; title2 'Parameter Estimates from Best Subset'; title3 'Creating an Excel Spreadsheet from the ODS HTML Destination'; run; ods html close; ods listing;
122
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
61
123
One More Example: Using ODS Style Statements in PROC REPORT Question:
How can I traffic-light an entire row of my PROC REPORT-generated output based on the values of one of the columns (variables) in the report?
Previously, we assigned colors to the individual values of the variables by applying a user-created Format (PVALF.) How can I change the appearance of an entire row of the output report?
Example: if the p-value is less than .05, make the entire row yellow and the text italic.
124
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
62
Variable DF Estimate StdErr tValue Probt Label ; variable/display 'Dependent/Variable' style(column)=[font_weight=bold]; DF/display 'Degrees/of/Freedom'; estimate/display 'Parameter/Estimate' style(column)=[font_weight=bold]; stderr/display 'Standard/Error' ; tvalue/display 'Test/Statistic'; probt/display 'P/Value' style(column)=[font_weight=bold]; define label/'Variable/Label' style(column)=[font_weight=bold];
125
126
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
63
127
128
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
64
PROC DOCUMENT
The new DOCUMENT destination allows you to
Store ODS objects in raw form as documents Documents can be
Modified/edited Replayed Saved for future use
129
Submitting the ODSDOCUMENT command opens the new (to SAS 9) Document Window
dm 'odsdocument';
The Document Window can also be opened with the DM (Display Manager) Command
130
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
65
By opening (and then closing) the DOCUMENT Destination, a document called MYDOC1 is created and shown in the DOCUMENT Window. By default, documents are temporary files and are stored in the WORK Library. 131
132
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
66
134
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
67
135
136
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
68
137
138
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
69
140
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
70
141
SAS Institute Technical Support Resources for ODS can be found on their web site at: http://support.sas.com/rnd/base/ 142
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
71
Lauren Haworth, author of SAS BBU texts Output Delivery System: The Basics and of PROC TABULATE By Example has placed several of her SAS user group papers on her web site. You can browse/download them from www.laurenhaworth.com/publications.htm
143
144
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
72
Delivery System
145
Questions? Comments?
146
Copyright 2003 Sierra Information Services, Inc. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any other means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, Sierra Information Inc. SAS is a trademark of SAS Institute in the USA and other countries. indicates USA registration. Revised 10 Jan 2003
73