Previous Page | Next Page

Getting Started with the Output Delivery System

A Quick Start to Using ODS


The Purpose of These Examples

The following examples are designed to help you to begin using ODS quickly. Use them to learn how to produce output that contains more interesting formatting. Then, to learn more about the depth, breadth, and true power of ODS, see Introduction to the Output Delivery System.


Creating Listing Output

Creating the listing output is simple--just run a DATA step or PROC step as usual. By default, the LISTING destination is on, and the DATA step and Base SAS procedures create listing output through ODS:

options source pagesize=60 linesize=80 nodate;

data employee_data;
   input IDNumber $ 1-4 LastName $ 9-19 FirstName $ 20-29
         City $ 30-42 State $ 43-44 /
         Gender $ 1 JobCode $ 9-11 Salary 20-29 @30 Birth date9.
         @43 Hired date9. HomePhone $ 54-65;
   format birth hired date9.;

            datalines;
1919    Adams      Gerald    Stamford     CT
M       TA2        34376     15SEP48      07JUN75    203/781-1255
1653    Alexander  Susan     Bridgeport   CT
F       ME2        35108     18OCT52      12AUG78    203/675-7715
1400    Apple      Troy      New York     NY
M       ME1        29769     08NOV55      19OCT78    212/586-0808
1350    Arthur     Barbara   New York     NY
F       FA3        32886     03SEP53      01AUG78    718/383-1549
1401    Avery      Jerry     Paterson     NJ
M       TA3        38822     16DEC38      20NOV73    201/732-8787
1499    Barefoot   Joseph    Princeton    NJ
M       ME3        43025     29APR42      10JUN68    201/812-5665
1101    Baucom     Walter    New York     NY
M       SCP        18723     09JUN50      04OCT78    212/586-8060
1333    Blair      Justin    Stamford     CT
M       PT2        88606     02APR49      13FEB69    203/781-1777
1402    Blalock    Ralph     New York     NY
M       TA2        32615     20JAN51      05DEC78    718/384-2849
1479    Bostic     Marie     New York     NY
F       TA3        38785     25DEC56      08OCT77    718/384-8816
1403    Bowden     Earl      Bridgeport   CT
M       ME1        28072     31JAN57      24DEC79    203/675-3434
1739    Boyce      Jonathan  New York     NY
M       PT1        66517     28DEC52      30JAN79    212/587-1247
1658    Bradley    Jeremy    New York     NY
M       SCP        17943     11APR55      03MAR80    212/587-3622
1428    Brady      Christine Stamford     CT
F       PT1        68767     07APR58      19NOV79    203/781-1212
1407    Grant      Daniel    Mt. Vernon   NY
M       PT1        68096     26MAR57      21MAR78    914/468-1616
1114    Green      Janice    New York     NY
F       TA2        32928     21SEP57      30JUN75    212/588-1092
;

proc print data=employee_data(obs=12);
   id idnumber;
   title 'Personnel Data';
run; 

Listing Output

                                 Personnel Data                                1

      ID                   First                                        Job
    Number    LastName     Name           City       State    Gender    Code

     1919     Adams        Gerald      Stamford       CT        M       TA2
     1653     Alexander    Susan       Bridgeport     CT        F       ME2
     1400     Apple        Troy        New York       NY        M       ME1
     1350     Arthur       Barbara     New York       NY        F       FA3
     1401     Avery        Jerry       Paterson       NJ        M       TA3
     1499     Barefoot     Joseph      Princeton      NJ        M       ME3
     1101     Baucom       Walter      New York       NY        M       SCP
     1333     Blair        Justin      Stamford       CT        M       PT2
     1402     Blalock      Ralph       New York       NY        M       TA2
     1479     Bostic       Marie       New York       NY        F       TA3
     1403     Bowden       Earl        Bridgeport     CT        M       ME1
     1739     Boyce        Jonathan    New York       NY        M       PT1

      ID
    Number    Salary        Birth        Hired     HomePhone

     1919      34376    15SEP1948    07JUN1975    203/781-1255
     1653      35108    18OCT1952    12AUG1978    203/675-7715
     1400      29769    08NOV1955    19OCT1978    212/586-0808
     1350      32886    03SEP1953    01AUG1978    718/383-1549
     1401      38822    16DEC1938    20NOV1973    201/732-8787
     1499      43025    29APR1942    10JUN1968    201/812-5665
     1101      18723    09JUN1950    04OCT1978    212/586-8060
     1333      88606    02APR1949    13FEB1969    203/781-1777
     1402      32615    20JAN1951    05DEC1978    718/384-2849
     1479      38785    25DEC1956    08OCT1977    718/384-8816
     1403      28072    31JAN1957    24DEC1979    203/675-3434
     1739      66517    28DEC1952    30JAN1979    212/587-1247

Listing output is the default format; therefore, when you request another format, your programs will create both listing output and output in the requested format. To prevent listing output from being created, use this statement:

ods listing close;


Creating Output in HTML Format

If you want to display output from a SAS program from the Web, you can use ODS to create output that is formatted in Hypertext Markup Language (HTML). To create HTML output, use the ODS HTML statement:

ods html file='external-file-for-HTML-output';

If you do not want to generate listing output in addition to the HTML output, then use this statement:

ods listing close;

The following program contains a PROC PRINT step that produces output in HTML, but does not produce the default listing output. You can browse this output with Internet Explorer, Netscape, or any other browser that fully supports HTML 3.2 or later.

ods listing close;
ods html file='external-file-for-HTML-output';

proc print data=employee_data(obs=12);
   id idnumber;
   title 'Personnel Data';
run;

ods html close;
ods listing;

Note the two ODS statements that follow the PROC PRINT step. To be able to browse your HTML files in a browser, you must execute the ODS HTML CLOSE statement. It is simply good practice to reset ODS to listing output, which is the default setting.

HTML 3.2 Output

 Note about figure

[HTML 3.2 Output]


Producing Output in Multiple Formats at the Same Time

A simple way to produce output in multiple formats at one time is to produce the default listing output and then request an additional format, such as HTML, PDF, RTF, or PostScript.

ods html file='HTML-file-pathname.html';
ods pdf file='PDF-file-pathname.pdf';
ods rtf file='RTF-file-pathname.rtf';
ods ps file='PS-file-pathname.ps';

proc print data=employee_data(obs=12);
   id idnumber;
   title 'Personnel Data';
run;

ods  _all_  close;
ods listing;

Note the two ODS statements that follow the PROC statement. The first one closes all files so that you can use them (for example, you could browse the HTML file or send the PDF file to a printer). The final statement opens the LISTING destination so that ODS returns to producing listing output for subsequent DATA or PROC steps in the current session.

HTML 3.2 Output

 Note about figure

[HTML 3.2 Output]

PDF Output

 Note about figure

[PDF Output]

RTF Output

 Note about figure

[RTF Output]

PostScript Output

 Note about figure

[PostScript Output]

Listing Output

 Note about figure
                                         Personnel Data                                         5

   ID             First                            Job
 Number LastName  Name        City    State Gender Code Salary     Birth     Hired  HomePhone

  1919  Adams     Gerald   Stamford    CT     M    TA2   34376 15SEP1948 07JUN1975 203/781-1255
  1653  Alexander Susan    Bridgeport  CT     F    ME2   35108 18OCT1952 12AUG1978 203/675-7715
  1400  Apple     Troy     New York    NY     M    ME1   29769 08NOV1955 19OCT1978 212/586-0808
  1350  Arthur    Barbara  New York    NY     F    FA3   32886 03SEP1953 01AUG1978 718/383-1549
  1401  Avery     Jerry    Paterson    NJ     M    TA3   38822 16DEC1938 20NOV1973 201/732-8787
  1499  Barefoot  Joseph   Princeton   NJ     M    ME3   43025 29APR1942 10JUN1968 201/812-5665
  1101  Baucom    Walter   New York    NY     M    SCP   18723 09JUN1950 04OCT1978 212/586-8060
  1333  Blair     Justin   Stamford    CT     M    PT2   88606 02APR1949 13FEB1969 203/781-1777
  1402  Blalock   Ralph    New York    NY     M    TA2   32615 20JAN1951 05DEC1978 718/384-2849
  1479  Bostic    Marie    New York    NY     F    TA3   38785 25DEC1956 08OCT1977 718/384-8816
  1403  Bowden    Earl     Bridgeport  CT     M    ME1   28072 31JAN1957 24DEC1979 203/675-3434
  1739  Boyce     Jonathan New York    NY     M    PT1   66517 28DEC1952 30JAN1979 212/587-1247

Previous Page | Next Page | Top of Page