Chapter Contents |
Previous |
Next |
Definition |
In the past, the program output has generally referred to the outcome of a SAS procedure step. You could send this output to the Output window if you were working in a windowing environment, to an output device if you were working in line mode, or to a file if you used PROC PRINTTO or SAS system options. With the advent of the Output Delivery System, "output" takes on a much broader meaning. The following figure illustrates the concept of output for Version 8 SAS. Definitions of the terms in the figure follow.
Model of the Production of ODS Output
Note: Not all
procedures use a table definition.
Procedures like PROC CHART and PROC TIMEPLOT need to use a monospace
font to correctly align their results. Such procedures do not use a table
definition. The HTML and Printer output that they produce does not substantially
differ from the Listing output. You cannot alter their HTML or Printer output
except by specifying a different style definition.
Procedures like PROC PRINT, PROC REPORT, and PROC TABULATE produce an endless variety of results, depending on how you use the procedures. These procedures do not use a table definition either. However, both PROC REPORT and PROC TABULATE provide ways for you to customize their HTML and Printer output. For more information, see "Fundamental Concepts for Using Base SAS Procedures" in the SAS Procedures Guide, as well as the sections on PROC REPORT and PROC TABULATE procedures in the same document.
Note: Although
many output objects include a table definition, not all do. In some cases
the output object is no more than the data component.
Traditional SAS output is, then, one kind of ODS output (Listing output), but it is no longer the only kind. For complete information about ODS, see The Complete Guide to the SAS Output Delivery System.
ODS Destinations |
ODS currently supports four destinations: the HTML destination, the Listing destination, the Output destination, and the Printer destination. ODS destinations can be open or closed. When a destination is open, ODS can send output objects to it. When a destination is closed, ODS cannot send output objects to it. An open destination uses system resources even if you use the selection and exclusion features of ODS to exclude all output objects from the destination. (See Using Selection and Exclusion Lists.) Therefore, to conserve resources, close all unnecessary destinations.
You open and close a destination with the appropriate ODS statement (ODS HTML, ODS LISTING, ODS PRINTER, or ODS OUTPUT). By default, the Listing destination is open, and all other destinations are closed. Consequently, if you do nothing, your SAS programs run and produce Listing output, just as they did in previous releases of SAS before ODS was available.
Using Selection and Exclusion Lists |
To see the contents of the lists use the ODS SHOW statement, which writes the lists to the SAS log. The following table shows the default lists:
ODS Destination | Default List |
---|---|
HTML | SELECT ALL |
Listing | SELECT ALL |
Output | EXCLUDE ALL |
Printer | SELECT ALL |
Overall | SELECT ALL |
Example 1: Using the Default Table Definition |
/* The OPTIONS statement controls several aspects of the */ /* Listing output. */ options pagesize=60 linesize=64 nodate pageno=1; title 'Leading Grain Producers'; proc format; value $cntry 'BRZ'='Brazil' 'CHN'='China' 'IND'='India' 'INS'='Indonesia' 'USA'='United States'; run; /* The DATA step does not create a data set. Instead, */ /* it creates a data component and, eventually, an */ /* output object. */ data _null_; length Country $ 3 Type $ 5; input Year country $ type $ Kilotons; format country $cntry.; label type='Grain'; /* The combination of the fileref PRINT and the ODS */ /* option in the FILE statement routes the DATA step */ /* output to ODS. The only open ODS destination is */ /* the Listing destination, which is open by default. */ /* Because no suboptions are specified, ODS uses the */ /* default DATA step table definition. */ file print ods; /* The _ODS_ option in the PUT statement writes all */ /* the variables to its buffer. Then the PUT statement */ /* writes to the data component. */ put _ods_; datalines; 1995 BRZ Wheat 1516 1995 BRZ Rice 11236 1995 BRZ Corn 36276 1995 CHN Wheat 102207 1995 CHN Rice 185226 1995 CHN Corn 112331 1995 IND Wheat 63007 1995 IND Rice 122372 1995 IND Corn 9800 1995 INS Wheat . 1995 INS Rice 49860 1995 INS Corn 8223 1995 USA Wheat 59494 1995 USA Rice 7888 1995 USA Corn 187300 1996 BRZ Wheat 3302 1996 BRZ Rice 10035 1996 BRZ Corn 31975 1996 CHN Wheat 109000 1996 CHN Rice 190100 1996 CHN Corn 119350 1996 IND Wheat 62620 1996 IND Rice 120012 1996 IND Corn 8660 1996 INS Wheat . 1996 INS Rice 51165 1996 INS Corn 8925 1996 USA Wheat 62099 1996 USA Rice 7771 1996 USA Corn 236064 ;
In the following output, the default table definition produces a column for each variable in the DATA step. The order of the columns is determined by their order in the program data vector. Because no attributes are specified for individual columns, ODS uses the default column headers and formats.
Listing Output Created with the Default DATA Step Table Definition
Leading Grain Producers 1 Country Grain Year Kilotons Brazil Wheat 1995 1516 Brazil Rice 1995 11236 Brazil Corn 1995 36276 China Wheat 1995 102207 China Rice 1995 185226 China Corn 1995 112331 India Wheat 1995 63007 India Rice 1995 122372 India Corn 1995 9800 Indonesia Wheat 1995 . Indonesia Rice 1995 49860 Indonesia Corn 1995 8223 United States Wheat 1995 59494 United States Rice 1995 7888 United States Corn 1995 187300 Brazil Wheat 1996 3302 Brazil Rice 1996 10035 Brazil Corn 1996 31975 China Wheat 1996 109000 China Rice 1996 190100 China Corn 1996 119350 India Wheat 1996 62620 India Rice 1996 120012 India Corn 1996 8660 Indonesia Wheat 1996 . Indonesia Rice 1996 51165 Indonesia Corn 1996 8925 United States Wheat 1996 62099 United States Rice 1996 7771 United States Corn 1996 236064 |
Example 2: Selecting Variables for the Data Component |
Operating Environment Information: This example uses file names that may not be valid in all operating environments. To successfully run the example in your operating environment, you may need to change the file specifications. See the SAS documentation for your operating environment.
/* The OPTIONS statement controls several aspects of the */ /* Listing output. None of these options affects the HTML */ /* output. */ options pagesize=60 linesize=64 nodate pageno=1; proc format; value $cntry 'BRZ'='Brazil' 'CHN'='China' 'IND'='India' 'INS'='Indonesia' 'USA'='United States'; /* The ODS HTML statement opens the HTML destination and */ /* creates HTML output. It sends all output objects to the */ /* external file selectvars-body.htm in the current */ /* directory. */ ods html body='selectvars-body.htm'; title 'Leading Grain Producers'; title2 'for 1996'; /* The DATA step does not create a data set. Instead, it */ /* creates a data component and, eventually, an output */ /* object. */ data _null_; length Country $ 3 Type $ 5; input Year country $ type $ Kilotons; if year=1996; format country $cntry.; label type='Grain'; /* The combination of the fileref PRINT and the ODS option */ /* in the FILE statement routes the results of the DATA */ /* step to ODS. Two ODS destinations, the Listing and the */ /* HTML destinations, are open. Because no table definition*/ /* is specified, ODS uses the default DATA step definition.*/ /* The VARIABLES= suboption specifies the three variables */ /* that appear in the output. */ file print ods=(variables=(country type kilotons)); /* The _ODS_ option in the PUT statement writes all the */ /* variables to its buffer. Then the PUT statement */ /* writes to the data component. */ put _ods_; datalines; 1995 BRZ Wheat 1516 1995 BRZ Rice 11236 1995 BRZ Corn 36276 1995 CHN Wheat 102207 1995 CHN Rice 185226 1995 CHN Corn 112331 1995 IND Wheat 63007 1995 IND Rice 122372 1995 IND Corn 9800 1995 INS Wheat . 1995 INS Rice 49860 1995 INS Corn 8223 1995 USA Wheat 59494 1995 USA Rice 7888 1995 USA Corn 187300 1996 BRZ Wheat 3302 1996 BRZ Rice 10035 1996 BRZ Corn 31975 1996 CHN Wheat 109000 1996 CHN Rice 190100 1996 CHN Corn 119350 1996 IND Wheat 62620 1996 IND Rice 120012 1996 IND Corn 8660 1996 INS Wheat . 1996 INS Rice 51165 1996 INS Corn 8925 1996 USA Wheat 62099 1996 USA Rice 7771 1996 USA Corn 236064 ; /* The ODS HTML statement closes the HTML destination */ /* and all the files that are associated with it. You */ /* must close the destination before you can view the */ /* output with a browser. */ ods html close;
Listing Output Produced by the Listing Destination
Leading Grain Producers 1 for 1996 Country Grain Kilotons Brazil Wheat 3302 Brazil Rice 10035 Brazil Corn 31975 China Wheat 109000 China Rice 190100 China Corn 119350 India Wheat 62620 India Rice 120012 India Corn 8660 Indonesia Wheat . Indonesia Rice 51165 Indonesia Corn 8925 United States Wheat 62099 United States Rice 7771 United States Corn 236064 |
Body File Produced by the HTML Destination
Example 3: Specifying Attributes for a Column |
Operating Environment Information: This example uses file names that may not be valid in all operating environments. To successfully run the example in your operating environment, you may need to change the file specifications. See the SAS documentation for your operating environment.
/* The OPTIONS statement controls several aspects of the */ /* Listing output. NODATE and PAGENO= also affect the */ /* Printer output. None of these options affects the HTML */ /* output. */ options pagesize=60 linesize=64 nodate pageno=1; proc format; value $cntry 'BRZ'='Brazil' 'CHN'='China' 'IND'='India' 'INS'='Indonesia' 'USA'='United States'; /* The ODS HTML statement opens the HTML destination and */ /* creates HTML output. Subsequent output objects go to */ /* the body file. CONTENTS= and FRAME= create a frame file*/ /* that includes a table of contents that links to the */ /* contents of the body file. The body file also appears */ /* in the frame. The ODS PRINTER statement opens the */ /* Printer destination and creates Printer output. It */ /* sends all output objects to the external file */ /* attribs.ps in the current directory. */ ods html body='attribs-body.htm' contents='attribs-contents.htm' frame='attribs-frame.htm'; ods printer file='attribs.ps'; title 'Leading Grain Producers'; title2 'for 1996'; /* The DATA step does not create a data set. Instead, it */ /* creates a data component and, eventually, an output */ /* object. */ data _null_; length Country $ 3 Type $ 5; input Year country $ type $ Kilotons; if year=1996; format country $cntry.; label type='Grain'; /* The combination of the fileref PRINT and the ODS */ /* option in the FILE statement routes the results of */ /* the DATA step to ODS. Three ODS destinations-the */ /* Listing,the HTML, and the Printer destinations-are */ /* open. Because no table definition is specified, ODS */ /* uses the default DATA step definition. */ file print ods=(objectlabel='1996 Grain Production' /* The VARIABLES= suboption specifies the three variables */ /* that appear in the output. */ variables=(country type(label='Type of Grain') kilotons(format=comma12.)) ); /* The _ODS_ option in the PUT statement writes all */ /* the variables to its buffer. Then the PUT statement */ /* writes to the data component. */ put _ods_; datalines; 1995 BRZ Wheat 1516 1995 BRZ Rice 11236 1995 BRZ Corn 36276 1995 CHN Wheat 102207 1995 CHN Rice 185226 1995 CHN Corn 112331 1995 IND Wheat 63007 1995 IND Rice 122372 1995 IND Corn 9800 1995 INS Wheat . 1995 INS Rice 49860 1995 INS Corn 8223 1995 USA Wheat 59494 1995 USA Rice 7888 1995 USA Corn 187300 1996 BRZ Wheat 3302 1996 BRZ Rice 10035 1996 BRZ Corn 31975 1996 CHN Wheat 109000 1996 CHN Rice 190100 1996 CHN Corn 119350 1996 IND Wheat 62620 1996 IND Rice 120012 1996 IND Corn 8660 1996 INS Wheat . 1996 INS Rice 51165 1996 INS Corn 8925 1996 USA Wheat 62099 1996 USA Rice 7771 1996 USA Corn 236064 ; /* The ODS HTML statement closes the HTML destination and */ /* all the files that are associated with it. You must */ /* close the destination before you can view the output */ /* with a browser. The ODS PRINTER statement closes the */ /* Printer destination. You must close the destination */ /* before you can print the output on a physical printer. */ ods html close; ods printer close;
In the following Listing output, the label that is supplied as an attribute for the variable Grain becomes its column header. The format for Kilotons was supplied as an attribute in the ODS= option in the FILE statement.
Listing Output Produced by the Listing Destination
Leading Grain Producers 1 for 1996 Type of Country Grain Kilotons Brazil Wheat 3,302 Brazil Rice 10,035 Brazil Corn 31,975 China Wheat 109,000 China Rice 190,100 China Corn 119,350 India Wheat 62,620 India Rice 120,012 India Corn 8,660 Indonesia Wheat . Indonesia Rice 51,165 Indonesia Corn 8,925 United States Wheat 62,099 United States Rice 7,771 United States Corn 236,064 |
In the following HTML output, the object's label, which was supplied by OBJECTLABEL=, appears in the table of contents as the link to the output object. In the body file, the label that is supplied as an attribute for the variable Grain becomes its column header. The format for Kilotons was supplied as an attribute in the ODS= option in the FILE statement.
Frame File Produced by the HTML Destination
In the following Printer output, the label that is supplied as an attribute for the variable Grain becomes its column header. The format for Kilotons was supplied as an attribute in the ODS= option in the FILE statement.
Output from the Printer Destination
Example 4: Building a Custom Table Definition for the TopN Report |
Operating Environment Information: This example uses file names that may not be valid in all operating environments. To successfully run the example in your operating environment, you may need to change the file specifications. See the SAS documentation for your operating environment.
/* The OPTIONS statement controls several aspects of the */ /* Listing output. None of these options affect the HTML */ /* output. */ options nodate pageno=1 pagesize=60 linesize=72; proc format; value yrFmt . = " All"; value $schFmt ' ' = "All "; run; /* The data set Charity contains information about high */ /* school students' volunteer work for charity. The */ /* variables give the name of the high school, the year of */ /* the fundraiser, the first name of each student, the */ /* amount of money that each student raised, and the number*/ /* of hours that each student volunteered. */ data Charity; input School $ 1-7 Year 9-12 Name $ 14-20 moneyRaised 22-26 hoursVolunteered 28-29; format moneyRaised dollar8.2; format hoursVolunteered f3.0; format Year yrFmt.; format School schFmt.; label School = "Schools"; label Year = "Years"; retain yearmin yearmax; yearmin=min(yearmin,year); yearmax=max(yearmax,year); call symput('first_year',put(yearmin,4.)); call symput('last_year', put(yearmax,4.)); datalines; Monroe 1992 Allison 31.65 19 Monroe 1992 Barry 23.76 16 Monroe 1992 Candace 21.11 5 ... more data lines ... Kennedy 1994 Sid 27.45 25 Kennedy 1994 Will 28.88 21 Kennedy 1994 Morty 34.44 25 ; /* This PROC MEANS step analyzes the data for the one way */ /* combination of the class variables and across all */ /* observations. It creates an output data set that */ /* includes variables for the total and average amount of */ /* money raised. The data set also includes new variables */ /* for the top three amounts of money raised, the names of */ /* the three students who raised the money, the years when */ /* the students raised the money, and the schools that the */ /* students attended. For a detailed explanation of the */ /* MEANS procedure, see the SAS Procedures Guide. */ proc means data=Charity descendTypes charType noprint; class School Year; var moneyRaised; types () School year; output out=top3list sum= mean= idgroup ( max(moneyRaised) out[3](moneyRaised name school year)= ) / autoname; run; /* The PROC PRINT step generates traditional Listing */ /* output of the output data set that PROC MEANS created. */ proc print data=top3list noobs; title 'Fund Raising Results'; run; title; /* The ODS HTML statement opens the HTML destination and */ /* creates HTML output. It sends all output objects to the */ /* external file topn-body.htm in the current directory. */ /* Some browsers require an extension of .htm or .html on */ /* the filename. */ ods html body='topn-body.htm'; /* The DEFINE statement creates the table definition */ /* means.topn in the first template store in the path that */ /* is available to write to. BY default, this template */ /* store is SASUSER.TEMPLAT. */ proc template; define table means.topn; mvar first_year last_year sysdate9; /* The COLUMN statement declares these symbols as columns */ /* in the table and specifies their order in the table. */ /* If a column name appears in parentheses, PROC TEMPLATE */ /* stacks the values of all variables that use that column*/ /* definition one below the other in the output object. */ /* Variables are assigned a column definition in the DATA */ /* step that appears later in the program. */ column class sum mean (raised) (name) (school) (year); /* These three table attributes affect the presentation */ /* of the output object in the Listing output. They have */ /* no effect on its presentation in the HTML output. */ /* DOUBLE_SPACE= double spaces the rows of the output */ /* object. OVERLINE= and UNDERLINE= draw a continuous */ /* line before the first row of the table and after the */ /* last row of the table. */ double_space=on; overline=on; underline=on; /* The HEADER statement declares table_header_1 and */ /* table_header_2 as headers in the table and specifies */ /* the order in which the headers appear in the output */ /* object. */ header table_header_1 table_header_2; /* The DEFINE statement and its substatement and */ /* attribute define table_header_1. The TEXT statement */ /* specifies the text of the header. The STYLE= attribute */ /* alters the style element that renders the table header.*/ /* The END statement ends the header definition. */ define table_header_1; text "Top Three Fund Raisers"; style=header{font_size=6}; end; /* The DEFINE statement and its substatement and */ /* attribute define table_header_2. The TEXT statement */ /* uses text and the macro variables FIRST_YEAR and */ /* LAST_YEAR to specify the contents of the header. */ /* The END statement ends the header definition. */ define table_header_2; text "from " first_year " to " last_year; space=1; end; /* The DEFINE statement and its substatement and */ /* attribute define table_footer. The FOOTER argument */ /* declares table_footer as a footer. */ define footer table_footer; text "(report generated on " sysdate9 ")"; split="*"; style=header{font_size=2}; end; /* The DEFINE statement and its attributes create the */ /* column definition class. (The COLUMN statement */ /* earlier in the program declared class as a column.) */ define class; generic=on; id=on; vjust=top; style=data; end; /* Each of these DEFINE statements and its attributes */ /* creates a column definition. The END statement ends */ /* the definition. */ define sum; generic=on; header="Total Dollars Raised"; vjust=top; end; define mean; generic=on; header="Average Dollars per Student"; vjust=top; end; define raised; generic=on; header="Individual Dollars"; end; define name; generic=on; header="Student"; end; define school; generic=on; header="School"; end; define year; generic=on; header="Year"; end; /* This END statement ends the table definition. The RUN */ /* statement ends the PROC TEMPLATE step. */ end; run; /* This DATA step does not create a data set. Instead, it */ /* creates a data component and, eventually, an output */ /* object. The SET statement reads the data set TOP3LIST, */ /* which PROC MEANS created. */ data _null_; set top3list; /* The combination of the fileref PRINT and the ODS option */ /* in the FILE statement routes the results of the DATA */ /* step to ODS. The TEMPLATE= suboption tells ODS to use */ /* the table definition named means.topn, which was just */ /* created with PROC TEMPLATE. */ file print ods = ( template='means.topn' /* The COLUMNS= suboption places DATA step variables into */ /* columns that are defined in the table definition. */ columns=( class=school(generic=on) class=year(generic=on) sum=moneyRaised_sum(generic=on) mean=moneyRaised_mean(generic=on) raised=moneyRaised_1(generic=on) raised=moneyRaised_2(generic=on) raised=moneyRaised_3(generic=on) name=name_1(generic=on) name=name_2(generic=on) name=name_3(generic=on) school=school_1(generic=on) school=school_2(generic=on) school=school_3(generic=on) year=year_1(generic=on) year=year_2(generic=on) year=year_3(generic=on) ) ); /* The _ODS_ option and the PUT statement write the data values */ /* for all columns to the data component. */ put _ods_; run; /* The ODS HTML statement closes the HTML destination and all */ /* the files that are associated with it. You must close the */ /* destination before you can view the output with a browser. */ ods html close;
PROC PRINT Listing Output for the Output Data Set from PROC MEANS
Fund Raising Results 1 money money Raised_ Raised_ money money money School Year _TYPE_ _FREQ_ Sum Mean Raised_1 Raised_2 Raised_3 Kennedy All 10 53 $1575.95 $29.73 $72.22 $52.63 $43.89 Monroe All 10 56 $1616.80 $28.87 $78.65 $65.44 $56.87 All 1992 01 31 $892.92 $28.80 $55.16 $53.76 $52.63 All 1993 01 32 $907.92 $28.37 $65.44 $47.33 $42.23 All 1994 01 46 $1391.91 $30.26 $78.65 $72.22 $56.87 All All 00 109 $3192.75 $29.29 $78.65 $72.22 $65.44 Name_1 Name_2 Name_3 School_1 School_2 School_3 Year_1 Year_2 Year_3 Luther Thelma Jenny Kennedy Kennedy Kennedy 1994 1992 1992 Willard Cameron L.T. Monroe Monroe Monroe 1994 1993 1994 Tonya Edward Thelma Monroe Monroe Kennedy 1992 1992 1992 Cameron Myrtle Bill Monroe Monroe Kennedy 1993 1993 1993 Willard Luther L.T. Monroe Kennedy Monroe 1994 1994 1994 Willard Luther Cameron Monroe Kennedy Monroe 1994 1994 1993 |
Using a Customized Table to Produce Listing Output
2 Top Three Fund Raisers from 1992 to 1994 Average Total Dollars Dollars per Individual Schools Years Raised Student Dollars Student School Year ---------------------------------------------------------------------- Kennedy All $1575.95 $29.73 $72.22 Luther Kennedy 1994 $52.63 Thelma Kennedy 1992 $43.89 Jenny Kennedy 1992 Monroe All $1616.80 $28.87 $78.65 Willard Monroe 1994 $65.44 Cameron Monroe 1993 $56.87 L.T. Monroe 1994 All 1992 $892.92 $28.80 $55.16 Tonya Monroe 1992 $53.76 Edward Monroe 1992 $52.63 Thelma Kennedy 1992 All 1993 $907.92 $28.37 $65.44 Cameron Monroe 1993 $47.33 Myrtle Monroe 1993 $42.23 Bill Kennedy 1993 All 1994 $1391.91 $30.26 $78.65 Willard Monroe 1994 $72.22 Luther Kennedy 1994 $56.87 L.T. Monroe 1994 All All $3192.75 $29.29 $78.65 Willard Monroe 1994 $72.22 Luther Kennedy 1994 $65.44 Cameron Monroe 1993 ---------------------------------------------------------------------- (report generated on 20JUL1999) |
HTML Output for the TopN Report
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.