• Print  |
  • Feedback  |

FOCUS AREAS

Return to ODS Packages

Base SAS

ODS PACKAGE Statement

The ODS PACKAGE statement opens, adds to, publishes, or closes one SAS Output Delivery System (ODS) package object. The ODS PACKAGE statement is production in SAS 9.2 and later.


Documentation

See the ODS PACKAGE statement in the SAS Output Delivery System: User's Guide, which is available in Base SAS documentation.


Example: Creating a Package

This example demonstrates the arguments for the ADD action.

  ods package add file="test.sas" mimetype="text/plain" path="sas/";
  /* Make a fileref */
  %filename (t, t20, sas);

  ods package open;

  /* Add this program and put it in the sas directory */
  ods package add file="t20.sas" path="sas" mimetype="text/plain";

  /* Add this program as a fileref in root directory of package */
  ods package add file=t;

  /* Add a data set from a named library */
  ods package add data=sashelp.class;

  /* Create a temporary data set in the default library (Work) */
  proc sort data=sashelp.class out=foo;
       by age;
  run;

  /* Add a data set from the default library (Work) */
  ods package add data=foo;

  /* Create the archive */
  ods package publish archive properties(archive_name="t20.spk"
                                         archive_path="./");

  /* Delete the ods package object */
  ods package close;


Example: Using a Package

This is a simple example of using a package with ODS with the default, unnamed package. The destination must specify a package option to connect with the package.

  ods package open;

  ods html package file="test_1.html" newfile=output;
      options obs=6;

  proc sort data=sashelp.class out=foo;
    by age;
  run;

  proc print ;
    by age;
  run;

  ods html close;

  ods package add file="test.sas" mimetype="text/plain" path="SAS";

  ods package publish archive properties(archive_name="test.spk" archive_path="./");

  ods package close clear;

The package created by the above example code looks like this:

  unzip -l test.spk
  Archive:  test.spk
    Length     Date   Time    Name
   --------    ----   ----    ----
         25  08-08-06 21:02   PackageMetaData
        126  08-08-06 21:02   SAS/test.sas
      24966  08-08-06 21:02   test_6.html
      25494  08-08-06 21:02   test_5.html
      25492  08-08-06 21:02   test_4.html
      25310  08-08-06 21:02   test_3.html
      25669  08-08-06 21:02   test_2.html
      25158  08-08-06 21:02   test_1.html
   --------                   -------
     152240                   8 files


Example: Using Multiple Packages and Destinations

A more complex example with named packages and multiple destinations looks like this:

  ods listing close;
  goptions dev=gif xpixels=480 ypixels=320;

  ods package open;
  ods package(foo) open;

  ods rtf package file="test2.rtf";
  ods html package(foo) file="test2_1.html" newfile=output;

  *options obs=5;

  proc sort data=sashelp.class out=foo;
    by age;
  run;

  proc print ;
    by age;
  run;

  proc gplot data=sashelp.class;
    plot height*weight;
    by name;
  run;
  quit;

  ods html close;

  ods package add file="test2.sas" mimetype="text/plain" path="SAS";
  ods package(foo) add file="test2.sas" mimetype="text/plain" path="SAS";

  ods package publish archive properties(archive_name="testRTF.spk" archive_path="./");
  ods package(foo) publish archive properties(archive_name="testHTML.spk" archive_path="./");

  ods package(foo) close clear;
  ods package close clear;

The two archives the example code publish look like this:

  unzip -l testHTML.spk

  Archive:  testHTML.spk
    Length     Date   Time    Name
   --------    ----   ----    ----
         25  08-08-06 21:19   PackageMetaData
       1004  08-08-06 21:19   SAS/test2.sas
       3009  08-08-06 21:19   gplot18.gif
      24103  08-08-06 21:19   test2_25.html
       2998  08-08-06 21:19   gplot17.gif
      24095  08-08-06 21:19   test2_24.html
       3002  08-08-06 21:19   gplot16.gif
      24095  08-08-06 21:19   test2_23.html
       3014  08-08-06 21:19   gplot15.gif
      24095  08-08-06 21:19   test2_22.html
       2983  08-08-06 21:19   gplot14.gif
      24095  08-08-06 21:19   test2_21.html
       2997  08-08-06 21:19   gplot13.gif
      24095  08-08-06 21:19   test2_20.html
       2986  08-08-06 21:19   gplot12.gif
      24095  08-08-06 21:19   test2_19.html
       2979  08-08-06 21:19   gplot11.gif
      24095  08-08-06 21:19   test2_18.html
       2990  08-08-06 21:19   gplot10.gif
      24095  08-08-06 21:19   test2_17.html
       2986  08-08-06 21:19   gplot9.gif
      24094  08-08-06 21:19   test2_16.html
       3002  08-08-06 21:19   gplot8.gif
      24094  08-08-06 21:19   test2_15.html
       2991  08-08-06 21:19   gplot7.gif
      24094  08-08-06 21:19   test2_14.html
       2988  08-08-06 21:19   gplot6.gif
      24094  08-08-06 21:19   test2_13.html
       2966  08-08-06 21:19   gplot5.gif
      24094  08-08-06 21:19   test2_12.html
       3001  08-08-06 21:19   gplot4.gif
      24094  08-08-06 21:19   test2_11.html
       2995  08-08-06 21:19   gplot3.gif
      24093  08-08-06 21:19   test2_10.html
       3008  08-08-06 21:19   gplot2.gif
      24093  08-08-06 21:19   test2_9.html
       2972  08-08-06 21:19   gplot1.gif
      24093  08-08-06 21:19   test2_8.html
       2981  08-08-06 21:19   gplot.gif
      24114  08-08-06 21:19   test2_7.html
      24966  08-08-06 21:19   test2_6.html
      25494  08-08-06 21:19   test2_5.html
      25492  08-08-06 21:19   test2_4.html
      25310  08-08-06 21:19   test2_3.html
      25669  08-08-06 21:19   test2_2.html
      25158  08-08-06 21:19   test2_1.html
   --------                   -------
     667786                   46 files


  unzip -l testRTF.spk

  Archive:  testRTF.spk
    Length     Date   Time    Name
   --------    ----   ----    ----
         25  08-08-06 21:19   PackageMetaData
       1004  08-08-06 21:19   SAS/test2.sas
     164261  08-08-06 21:19   test2.rtf
   --------                   -------
     165290                   3 files