Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next

ODS Output Formats

The ODS Output Formats sample shows different output formats supported by the Output Delivery System (ODS).

Sample data sets can be printed to any of the following output formats:


The Input Component

The sample uses a form submission that is controlled by JavaScript. Each of the sample links uses JavaScript to set one or more field values and submit the form. The sample has no input fields because it has no user-controlled options. You can access the different reports and program components from the default location:

   http://yourserver/sasweb/IntrNet8/dispatch/webods4.html

The Program Component

General Information

To begin generating HTML output by using ODS, submit the following statement:

   ods html ods-options path=&_tmpcat (url=&_replay) rs=none;

The ODS options control the type and destination of the HTML output that is generated by your program. At the end of your program, include the following line of code:

   ods html close;

The SAS source code for your program is placed between these two ODS statements. For more detailed information about using ODS with the Application Dispatcher, refer to The Output Delivery System (ODS).

Creating Output Formats

Use the name of the desired output destination in the ODS statements, as shown in the previous lines of code, which produce standard HTML output. The following table gives the values to be used for each output destination:

Output Destination Value
standard HTML html
comma separated values csv
Portable Document Format pdf
compact HTML chtml
plain HTML phtml
Rich Text Format rtf

The browser must be configured to handle the type of output you are producing; for example, PDF output requires Adobe Acrobat for viewing. The following example shows the code used to produce PDF output:

   ods pdf body=_webout;

   title "Data Set &dataset in PDF Format";

   proc print data=&dataset; run;

   ods pdf close;

Note: The XML sample uses the XML Library Engine instead of ODS. ODS can also be used to generate XML.

The content-type header must be set manually for some formats. For example, the RTF example sets the content-type header to application/msword with the following line of code:

   %let rv = %sysfunc(appsrv_header(Content-type,application/msword));

Checking for Errors

The following code is included in each of the sample output format programs. You can use this code to produce an error message in the event that there is a faulty or missing data set.

   %macro print_to_html;                                                                                                  
      %if not %sysfunc(exist(&dataset)) %then                                                                              
      %do;                                                                                                                 
         data _null_;                                                                                                       
            file _webout;                                                                                                    
            put '<HTML>';                                                                                                    
            put '<HEAD>';                                                                                                    
            put '<TITLE>Missing Data Set</TITLE>';                                                                           
            put '</HEAD>';                                                                                                   
            bgtype = symget('bgtype');                                                                                       
            if trim(upcase(bgtype))="COLOR" then put "<BODY BGCOLOR=&bg>";                                                   
            else if trim(upcase(bgtype))="IMAGE" then put '<BODY BACKGROUND="' "&bg" '">';                                   
            else put '<BODY>';                                                                                               
            put '<H1>Missing Data Set</H1>';                                                                                 
            put "Data set &dataset not found.";                                                                              
            put '</BODY>';                                                                                                   
            put '</HTML>';                                                                                                   
            run;                                                                                                             
         %goto done;                                                                                                        
      %end;                                                                                                                

Using ODS Styles

Most of the sample programs include ODS style code to set the output background to a specified color or image. The TEMPLATE procedure is used to create a temporary style with the desired background. For more information about ODS styles and PROC TEMPLATE, see The Output Delivery System (ODS).


Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next