SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110) Module 7: ODS Sample Programs: Module7_example1a.sas Module7_example1.sas

Size: px
Start display at page:

Download "SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110) Module 7: ODS Sample Programs: Module7_example1a.sas Module7_example1.sas"

Transcription

1 SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110) Module 7: ODS Sample Programs: Module7_example1a.sas Module7_example1.sas Mark Carpenter, Professor of StaKsKcs Department of MathemaKcs and StaKsKcs Phone: Office: Parker 364- A E- mail: carpedm@auburn.edu Web: hxp:// 1

2 Output Delivery System (ODS) Overview In the latest version of SAS software, all SAS/STAT procedures use the Output Delivery System (ODS) to manage their output. This includes managing the form in which the output appears as well as its organization and format. The default for SAS/STAT procedures is to produce the usual SAS listing file. However, by using the features of the Output Delivery System, you can make changes to the format and appearance of your SAS output. For example, you can display your output in hypertext markup language (HTML) display your output in Rich Text Format (RTF), PDF, or PostScript create SAS data sets directly from output tables select or exclude individual output objects customize the layout, format, and headers of your output ODS features can provide you with a powerful tool for managing your output. This chapter provides background material and illustrates typical applications of ODS with SAS/STAT software. 2

3 Using the Output Delivery System The ODS statement is a global statement that enables you to provide instructions to the Output Delivery System. You can use ODS statements to specify options for different ODS destinations, select templates to format your output, and select and exclude output. You can also display the names of individual output tables as they are generated. In order to select, exclude, or modify a table, you must first know its name. You can obtain the table names in several ways: For any SAS/STAT procedure, you can obtain table names from the individual procedure chapter or from the individual procedure section of the SAS online Help system. For any SAS procedure, you can use the SAS Explorer window to view the names of the tables created in your SAS run (see the section " Using ODS with the SAS Explorer" for more information). For any SAS procedure, you can use the ODS TRACE statement to find the names of tables created in your SAS run. The ODS TRACE statement writes identifying information to the SAS log (or, optionally, to the SAS listing) for each generated output table. 3

4 /* ODS module7_example1.sas */ /* A one- sample Xest can be used to compare a sample mean to a given value. This example, taken from Huntsberger and Billingsley (1989, p. 290), tests whether the mean length of a certain type of court case is 80 days using 20 randomly chosen cases. The data are read by the following DATA step: */ TITLE 'One- Sample t Test'; DATA 4me; INPUT DATALINES; ; 4

5 /* Specify the ODS TRACE ON statement prior to the procedure statements that create the output for which you want informakon. For example, the following statements write the trace record for the specific tables created in this TTEST procedure step. SEE LOG FILE AFTER RUNNING*/ ODS TRACE ON; PROC TTEST DATA=4me; ODS TRACE OFF; 5

6 11 ODS TRACE ON; 12 PROC TTEST DATA=Kme; Output Added: Name: StaKsKcs Label: StaKsKcs Template: Stat.TTest.StaKsKcs Path: Ttest.Kme.StaKsKcs Output Added: Name: ConfLimits Label: Confidence Limits Template: Stat.TTest.ConfLimits Path: Ttest.Kme.ConfLimits Output Added: Name: TTests Label: T- Tests Template: Stat.TTest.TTests Path: Ttest.Kme.TTests NOTE: PROCEDURE TTEST used (Total process Kme): real Kme 0.31 seconds cpu Kme 0.06 seconds 15 ODS TRACE OFF; 6

7 /* You can specify the tables that ODS selects or excludes with the ODS SELECT or ODS EXCLUDE statement. Suppose that you want to display only the tables of parameter eskmates from the preceding regression analysis. You can give any of the following statements (before invoking the REG procedure) to display both tables of parameter eskmates. */ *The following three ODS statements are idenkcal; ODS SELECT Stat.TTest.StaKsKcs; ODS SELECT TTest.StaKsKcs; ODS SELECT StaKsKcs; PROC TTEST DATA=4me; 7

8 *The following three ODS statements are idenkcal; ODS SELECT Stat.TTest.StaKsKcs; ODS SELECT TTest.StaKsKcs; ODS SELECT StaKsKcs; PROC TTEST DATA=4me; One- Sample t Test The TTEST Procedure Variable: Kme N Mean Std Dev Std Err Minimum Maximum

9 ODS SELECT Stat.TTest.TTests; ODS SELECT TTest.TTests; ODS SELECT TTests; PROC TTEST H0=80 DATA=4me; One- Sample t Test The TTEST Procedure Variable: Kme DF t Value Pr > t

10 *EXLUDE statements allow you to suppress some tables; ODS EXCLUDE Xests; PROC TTEST H0=80 DATA=4me; One- Sample t Test The TTEST Procedure Variable: Kme N Mean Std Dev Std Err Minimum Maximum Mean 95% CL Mean Std Dev 95% CL Std Dev

11 ODS EXCLUDE stakskcs; PROC TTEST H0=80 DATA=4me; One- Sample t Test The TTEST Procedure Variable: Kme Mean 95% CL Mean Std Dev 95% CL Std Dev DF t Value Pr > t

12 /* ODS OUTPUT statements can be used to create SAS datasets from the tables associated with the procedure*/ ODS OUTPUT STATISTICS=stats Xests=pvalue; ODS LISTING CLOSE; *no output produced; PROC TTEST H0=80 DATA=4me; 12

13 11 ODS TRACE ON; 12 PROC TTEST DATA=Kme; Output Added: Name: StaKsKcs Label: StaKsKcs Template: Stat.TTest.StaKsKcs Path: Ttest.Kme.StaKsKcs Output Added: Name: ConfLimits Label: Confidence Limits Template: Stat.TTest.ConfLimits Path: Ttest.Kme.ConfLimits Output Added: Name: TTests Label: T- Tests Template: Stat.TTest.TTests Path: Ttest.Kme.TTests NOTE: PROCEDURE TTEST used (Total process Kme): real Kme 0.31 seconds cpu Kme 0.06 seconds 15 ODS TRACE OFF; 13

14 14

15 15

16 /* ODS OUTPUT statements can be used to create SAS datasets from the tables associated with the procedure*/ ODS OUTPUT STATISTICS=stats Xests=pvalue; ODS LISTING CLOSE; *no output produced; PROC TTEST H0=80 DATA=4me; LOG FILE /* ODS OUTPUT statements can be used to 53 create SAS datasets from the tables 54 associated with the procedure*/ ODS OUTPUT STATISTICS=stats Xests=pvalue; 57 ODS LISTING CLOSE; *no output produced; 58 PROC TTEST H0=80 DATA=Kme; NOTE: The data set WORK.PVALUE has 1 observakons and 4 variables. NOTE: The data set WORK.STATS has 1 observakons and 13 variables. NOTE: PROCEDURE TTEST used (Total process Kme): real Kme 0.01 seconds cpu Kme 0.01 seconds 16

17 SAS Explorer 17

18 ODS OUTPUT STATISTICS=stats Xests=pvalue; ODS LISTING CLOSE; *no output produced; PROC TTEST H0=80 DATA=4me; ODS OUTPUT STATISTICS=stats1 Xests=pvalue; ODS LISTING CLOSE; *no output produced; PROC TTEST H0=80 DATA=4me; ODS OUTPUT; ODS LISTING; *lets output be produced again; PROC PRINT DATA=stats1; Suppresses output in the Output screen. Turns output back on Output screen. 18

19 ODS OUTPUT STATISTICS=stats2 (KEEP=LOWERCLMEAN MEAN UpperCLMean RENAME=(LowerClMean=LCL upperclmean=ucl)) Xests=pvalue; ODS LISTING CLOSE; PROC TTEST H0=80 DATA=4me; One- Sample t Test ODS LISTING CLOSE; PROC PRINT DATA=stats2; Obs Mean LCL UCL ODS LISTING; PROC PRINT DATA=stats2; 19

20 CREATING RTF, PDF, HTML USING ODS ODS html file='c:\stat6110\ods.html'; PROC PRINT DATA=4me; PROC PRINT DATA=stats2; ODS html close; ODS rp file='c:\stat6110\ods.rp'; PROC PRINT DATA=4me; PROC PRINT DATA=stats2; ODS rp close; ODS pdf file='c:\stat6110\ods.pdf'; PROC PRINT DATA=4me; PROC PRINT DATA=stats2; ODS pdf close; 20