Previous Page | Next Page

Directing SAS Log and SAS Procedure Output

Directing Procedure Output: ODS Examples


Overview of ODS Output

SAS supports three output formats for procedure output: the Output Delivery System (ODS), SAS/GRAPH, and the FORM subsystem.

Most of ODS is portable and documented elsewhere, including the SAS Output Delivery System: User's Guide and the SAS Language Reference: Dictionary. Two format options provided by ODS are HTML and XML. This section shows examples of how the ODS HTML and ODS XML statements are used and the steps that are required to route the output between operating environments. A SAS/GRAPH example is also provided.

In a mainframe environment, by default, ODS produces a binary file that contains embedded record-separator characters. While this approach means that the file is not restricted by the line-length restrictions on ASCII files, it also means that if you view the file in an editor, the lines all run together.

If you want to format the HTML files so that you can read them with an editor, use RECORD_SEPARATOR=NONE. In this case, ODS writes one line of HTML at a time to the file. When you use a value of NONE, the logical record length of the file that you are writing to must be at least as long as the longest line that ODS produces. If it is not, the HTML can wrap to another line at an inappropriate place. We recommend that you use rs=none if you are writing to a standard z/OS file, but not if you are writing to a UFS file. See Writing ODS XML Output to EBCDIC, ASCII Transfer to UNIX for an example that uses rs=none to format output.

Note:   The NLSCOMPATMODE system option might affect the format of outputs produced with ODS. If you are using ODS, set the NLSCOMPATMODE value to NONLSCOMPATMODE.  [cautionend]


Line-Feed Characters and Transferring Data between EBCDIC and ASCII


Overview of Transferring Data between EBCDIC and ASCII

When you exchange data between an operating environment that uses ASCII encoding and an operating environment that uses EBCDIC encoding, formatting errors can occur. EBCDIC and ASCII do not always use the same characters to indicate the end of a line of data. EBCDIC indicates the end of a line with either a line-feed character or a newline character. ASCII uses only the line-feed character to indicate the end of a line. If you exchange data between an EBCDIC operating environment, such as z/OS, and an ASCII operating environment, such as Windows, then you should use UNIX System Services (USS) encodings, which help prevent end-of-line formatting errors. USS encodings are used by default in NONLSCOMPATMODE, which is the default for SAS 9.2.


Details of Transferring Data

Software running on ASCII platforms requires that the end of the line be indicated by a line-feed character. When data is transferred from z/OS to a machine that supports ASCII encodings, formatting problems can occur, particularly in HTML output, because the EBCDIC newline character is not recognized.

SAS supports the following two sets of EBCDIC-based encodings for z/OS:

For more information about these encodings, see the SAS National Language Support (NLS): Reference Guide.

If you need to exchange data between ASCII and EBCDIC, you can specify USS encodings from the list of encodings in ENCODING System Option in the SAS National Language Support (NLS): Reference Guide. There are several language elements and commands that enable you to specify encodings when creating or exchanging data:


Viewing ODS Output on an External Browser

The following example stores ODS HTML output in a UNIX System Services (USS) file. You can then display the output in an external HTML browser with the universal resource locator (URL) appropriate to your site.

/* if needed, create web directory */
%sysexec mkdir '/u/myuid/public_html' ;

ods html 
/* specify locations of HTML files */
  body='examplb.htm'
  page='examplp.htm'
  contents='examplc.htm'
  frame='example.htm'
  path='/u/myuid/public_html'(url=none);

/* do not send output to proc output */
ods listing close;

title1 'z/OS UNIX System Services 
   Example';

proc plan seed=9544455;
  factors a=3 b=4 c=5 ordered; run;
  title1;
  quit;

/* close the HTML destination */
ods html close;

Here is a typical URL for this example:

http://corp.dept.com/~myuid/example.htm

For more information about viewing ODS output with a browser, see Using Remote Browsing with ODS Output.


Storing ODS HTML Output in a Sequential File, FTP from UNIX

The following example runs partly on SAS in the z/OS operating environment and partly on the command line in the UNIX operating environment.

ods html
/* specify HTML files and destination URLs */ 
  body='.seqb.htm'     (url='seqb.htm')
  page='.seqp.htm'     (url='seqp.htm')
  contents='.seqc.htm' (url='seqc.htm')
  frame='.seqf.htm'
  trantab=ascii;

/* do not send output to proc output destination*/
ods listing close;

title1 'z/OS HTML Example';

proc plan seed=9544455;
  factors a=3 b=4 c=5 ordered; run;
  title1;
  quit;

/* close the html destination */
ods html close;

When you use physical filename syntax and run in interactive mode, you are prompted to specify whether you want to create the files. You are not prompted in batch mode.

When you use JCL or a FILENAME statement, the disposition parameter controls file creation.

The TRANTAB= option generates ASCII stream files. Each line is terminated with a newline character. You cannot read ASCII stream files with TSO ISPF browse. The default file characteristics are record format VB and record length 8,196.

You might need to update links between the files after you transfer the files to UNIX. To avoid the need to update links, use the URL= option in the ODS statement to identify how you would like to generate the links.

This second part of the example transfers the ODS output file from z/OS to UNIX. Issue the following commands on a UNIX workstation:

ftp os390
...
ftp> binary
...
ftp> get 'myuid.seqb.html' 
     /u/myuid/public_html/seqb.htm
...

To view the output file, point your UNIX browser at the file that you moved to UNIX with FTP, using a URL such as

http://corp.dept.com/~myuid/seqb.htm


Storing ODS HTML Output in a z/OS PDSE, FTP from UNIX

The filename in this example stores ODS output as a member of a partitioned data set extended (PDSE).

/* create a PDSE */
filename ODSPDSE '.exampl.pdse'
  dsntype=library
  disp=(new,catlg) dsorg=po ;

ods html
/* specify HTML files and destination URLs */
  body='examplb'     (url='examplb.htm')
  page='examplp'     (url='examplp.htm')
  contents='examplc' (url='examplc.htm')
  frame='examplf'
  path='.exampl.pdse' (url=none)
  trantab=ascii;

/* do not send output to proc output destination */
ods listing close;

title1 'z/OS PDSE Example';

proc plan seed=9544455;
  factors a=3 b=4 c=5 ordered; run;
  title1;
  quit;

/* close the HTML destination */
ods html close;

The TRANTAB= option generates ASCII stream files. Each line is terminated with a newline character. You cannot read ASCII stream files with TSO ISPF browse.

You might need to update links between the files after you transfer the files to UNIX. To avoid the need to update links, use the URL= option in the ODS statement to identify how you would like to generate the links.

In the UNIX operating environment, use the following FTP command to transfer a file from the PDSE:

ftp> get 'myuid.exampl.pdse(examplb)'
     /u/myuid/public_html/examplb.html


Writing ODS HTML Output Directly to UNIX

The following example uses the FTP access method to write HTML output that is generated on z/OS directly to a UNIX file.

Each of the following FILENAME statements uses the FTP access method to specify a file on a UNIX host. Each file contains part of the ODS HTML output that is generated by this SAS job. You need to provide the correct host, user, password, and directory information for your site. See the section on the FILENAME, FTP access method in the SAS Language Reference: Dictionary for more information about the FTP access method options.

filename myfram ftp 'example_frame.htm'         /* Specify frame file */
                    cd='mydir'                  /* Specify directory  */
                    host='myhost.mycompany.com' /* Specify your host  */
                    user='myuser'               /* Specify user       */

                    pass='mypass'               /* Specify password   */
      /* or */      /* prompt */                /* Password prompting */

                    rcmd='site umask 022'       /* Set permissions to */
                                                /* -rw-r--r--         */
                    recfm=s                     /* binary transfer    */
                    debug;                      /* Write ftp messages */

filename mybody ftp 'example_body.htm'          /* Specify body file  */
                    cd='mydir'                  /* Specify directory  */
                    host='myhost.mycompany.com' /* Specify your host  */
                    user='myuser'               /* Specify user       */

                    pass='mypass'               /* Specify password   */
      /* or */      /* prompt */                /* Password prompting */

                    rcmd='site umask 022'       /* Set permissions to */
                                                /* -rw-r--r--         */
                    recfm=s                     /* binary transfer    */
                    debug;                      /* Write ftp messages */

filename mypage ftp 'example_page.htm'          /* Specify page file  */
                    cd='mydir'                  /* Specify directory  */
                    host='myhost.mycompany.com' /* Specify your host  */
                    user='myuser'               /* Specify user       */

                    pass='mypass'               /* Specify password   */
      /* or */      /* prompt */                /* Password prompting */

                    rcmd='site umask 022'       /* Set permissions to */
                                                /* -rw-r--r--         */
                    recfm=s                     /* binary transfer    */
                    debug;                      /* Write ftp messages */


filename mycont ftp 'example_contents.htm'      /* Specify contents   */
                    cd='mydir'                  /* Specify directory  */
                    host='myhost.mycompany.com' /* Specify your host  */
                    user='myuser'               /* Specify user       */

                    pass='mypass'               /* Specify password   */
      /* or */      /* prompt */                /* Password prompting */

                    rcmd='site umask 022'       /* Set permissions to */
                                                /* -rw-r--r--         */
                    recfm=s                     /* binary transfer    */
                    debug;                      /* Write ftp messages */


/* Specify the HTML files using the filerefs defined above */
ods html body=mybody
         page=mypage
         contents=mycont
         frame=myfram
         trantab=ascii;

/* Do not send output to proc output destination */
ods listing close;

title1 'z/OS FTP Access Method Example';
proc plan seed=9544455;
  factors a=3 b=4 c=5 ordered; run;
  title1;
  quit;

/* Close the HTML destination */
ods html close;


Writing ODS XML Output to ASCII, Binary FTP to UNIX

The following ODS XML example generates ASCII output with embedded record separators and does a binary transfer to UNIX.

/* Use FTP access method to direct the output to UNIX */

filename myxml ftp 'odsxml1.xml'               /* specify xml file   */
                   cd='public_html/ods_test'   /* specify directory  */
                   host='unix.corp.dept.com' /* specify host       */
                   user='userid'               /* specify user       */

                   /* pass='mypass' */         /* specify password   */
      /* or */     prompt                      /* password prompting */

                   rcmd='site umask 022'       /* set permissions to */
                                               /* -rw-r--r--         */
                   recfm=s                     /* binary transfer    */
                   debug;                      /* write ftp messages */


/* Don't write to output window */
ods listing close;

/* Specify XML file using fileref specified above        */
/* Specify ascii representation and do a binary transfer */
ods xml file=myxml
    trantab=ascii;

title1 'z/OS ODS XML Example - Binary transfer to UNIX';
proc plan seed=9544455; factors a=3 b=4 c=5 ordered; run;
title1;
quit;

/* Close the XML destination */
ods xml close;

To view the output file, point your UNIX browser at the file that you moved to UNIX with FTP, using a URL such as

http://corp.dept.com/~userid/ods_test/odsxml1.xml


Writing ODS XML Output to EBCDIC, ASCII Transfer to UNIX

This example generates ODS XML output in EBCDIC and uses RS=NONE to format the output for a text (ASCII) transfer to UNIX.

/* Use FTP access method to direct the output to UNIX */

filename myxml ftp 'odsxml2.xml'               /* specify xml file   */
                   cd='public_html/ods_test'   /* specify directory  */
                   host='unix.corp.dept.com' /* specify host       */
                   user='userid'               /* specify user       */

                   /* pass='mypass' */         /* specify password   */
      /* or */     prompt                      /* password prompting */

                   rcmd='site umask 022'       /* set permissions to */
                                               /* -rw-r--r--         */
                   recfm=v                     /* text transfer      */
                   debug;                      /* write ftp messages */


/* Don't write to output window */
ods listing close;

/* Specify XML file using fileref specified above                  */
/* Specify RS=NONE, generate EBCDIC and do a TEXT (ASCII) transfer */
ods xml file=myxml
        rs=none;

title1 'z/OS ODS XML Example - TEXT transfer to UNIX';
proc plan seed=9544455; factors a=3 b=4 c=5 ordered; run;
title1;
quit;

/* Close the XML destination */
ods xml close;

To view the output file, point your UNIX browser at the file that you moved to UNIX with FTP, using a URL such as

http://corp.dept.com/~userid/ods_text/odsxml2.xml


Directing ODS XML Output to UNIX System Services

The following example stores ODS XML output in a UNIX System Services file.

/* Don't write to output window */
ods listing close;

/* Direct output to UNIX System Services (USS) file */
/* Specify ascii representation */
ods xml file='/u/userid/public_html/odsxml3.xml'
        trantab=ascii;

title1 'z/OS ODS XML Example - Output to UNIX System Services';
proc plan seed=9544455; factors a=3 b=4 c=5 ordered; run;
title1;
quit;

/* Close the XML destination */
ods xml close;

To view the output file, point your UNIX browser at the file that you moved to UNIX System Services, using a URL such as

http://s390.corp.dept.com/~userid/ods_text/odsxml1.xml


Directing Procedure Output to a High-Quality Printer via ODS

Follow these steps to send high-resolution procedure output created with the Output Delivery System to a Universal Printing destination:

  1. Establish the print destination with the PRINTERPATH= option:

    options printerpath='prt23lj5';

    The OPTIONS statement assigns PRT23lJ5 as the default Universal printer. PRT23lJ5 remains the default printer for the duration of the SAS session, unless it is overridden by another OPTIONS statement.

  2. Identify the print destination to SAS:

    ods printer;

    The ODS PRINTER statement opens an ODS printer destination, enabling procedure output to be formatted for a high-resolution printer. Because the ODS PRINTER statement does not specify a filename or a fileref, ODS output is sent to the Universal Printing default printer (PRT23lJ5).

  3. Issue a print command:

    proc print data=sashelp.shoes;
       where region="Canada";
    run;

    PROC PRINT generates procedure output in ODS format.

  4. Remove the print destination:

    ods printer close;

    The ODS PRINTER CLOSE statement removes the ODS printing destination and sends the procedure output to PRT23lJ5. Subsequent procedure output is routed to the default Universal Printing destination.

Previous Page | Next Page | Top of Page