ODS PACKAGE Statement

The ODS PACKAGE statement opens, adds to, publishes, or closes one SAS Output Delivery System (ODS) package object.
Valid in: Anywhere
Category: Data Access
Requirement: The destination must specify the PACKAGE option to connect with the package.
See: ODS packages are used primarily with the Publishing Framework. For complete information about the Publishing Framework feature of SAS Integration Technologies, see SAS Publishing Framework: Developer's Guide.

Syntax

ODS PACKAGE (<name> ) OPEN <options> ;
ODS PACKAGE (<name> ) CLOSE <CLEAR> ;

Required Arguments

ADD
adds a file or data set to an ODS package using the specified Multipurpose Internet Mail Extensions (MIME) type.
Requirement:When using the ADD argument, you must also use the MIMETYPE=, FILE=, or DATA= arguments to specify a file or data set and a MIME type.
FILE="file-specification" <TEXT | BINARY>
specifies the file that you want to add to an ODS package.
file-specification
specifies one of the following:
external-file
is the name of an external file to add.
Requirement:You must enclose external-file in quotation marks.
fileref
is a file reference that has been assigned to an external file. Use the FILENAME statement to assign a fileref.
TEXT
specifies that the file is a text file.
BINARY
specifies that the file is a binary file.
Default:If you do not specify the TEXT or BINARY values, then the file is added as binary, unless it is a text file. Text files are added as text by default.
Restrictions:You can use the FILE= argument only with the ADD argument.

You cannot add a file and a data set to an ODS package.

Example:Use the following statement to add the Test.SAS file as plain text to the ODS package directory SAS:
ods package add file="test.sas" mimetype="text/plain" path="sas/"; 
DATA=member-specification
specifies the data set that you want to add to an ODS package. member-specification can be in the form libname.membername or membername.
Restrictions:You can use the DATA= argument only with the ADD argument.

You cannot add a file and a data set to an ODS package.

MIMETYPE=''string"
specifies the Multipurpose Internet Mail Extensions (MIME) type for the file or data set that you are adding to an ODS package.
Restriction:You can use the MIMETYPE= argument only with the ADD argument.
OPEN EXPIRATION= <'expiration-date'>
creates the ODS package object to which the ODS destinations can connect. The ODS package object holds the package metadata and tracks the locations of any files that are added to the package metadata.
Example:The following ODS PACKAGE statement opens an unnamed package with an abstract and a description:
  ods package open abstract="this is my abstract" description="this is
       description";
PUBLISH EXPIRATION=<'expiration-date'>
builds the ODS package and sends it to the chosen delivery transport.
expiration-date
specifies an expiration date for the package. The date must be a SAS date value.
Requirement:expiration-date must be enclosed in quotation marks.
CLOSE
deletes the package object. As long as you have not closed a package, you can publish it as many ways and times as you want.
Tip:Use the CLEAR option to remove files that have been added to the package.
transport
specifies the deliver transport to use with the PUBLISH action. transport can be one of the following:
ARCHIVE PROPERTIES(transport-property-1="value-1"transport-property-n="value-n"")
publishes a package to an archive. For a list of transport properties and their values, see the section on transport properties in the SAS Publishing Framework: Developer's Guide.
Example:The following statement publishes an ODS package to the archive Test.spk:
ods package publish archive  properties(archive_path="./"
     archive_name="test.spk");
EMAIL PROPERTIES(transport-property-1="value-1" . . . transport-property-n="value-n") ADDRESSES("e-mail-address-1" . . . "e-mail-address-n")
publishes a package to one or more e-mail addresses. For a list of transport properties and their values, see the section on transport properties in the SAS Publishing Framework: Developer's Guide.
Example:The following statement publishes an ODS package to the e-mail addresses your.email@company.com and your.second.email@company.com:
ods package publish email  addresses("your.email@company.com"
     "your.second.email@company.com")
    properties(archive_name="testPackage" archive_path="./"); 
QUEUE PROPERTIES(transport-property-1="value-1" . . . transport-property-n="value-n") QUEUES("queue-1" . . . "queue-n")
publishes a package to one or more message queues. For a list of transport properties and their values, see the section on transport properties in the SAS Publishing Framework: Developer's Guide.
SUBSCRIBERS PROPERTIES(transport-property-1="value-1" . . . transport-property-n="value-n")
publishes a package to subscribers who are associated with the specified channel. For a list of transport properties and their values, see the section on transport properties in the SAS Publishing Framework: Developer's Guide.
WEBDAV PROPERTIES(transport-property-1="value-1" . . . transport-property-n="value-n")
publishes a package to a WebDAV-compliant server. For a list of transport properties and their values, see the section on transport properties in the SAS Publishing Framework: Developer's Guide.

Optional Arguments

ABSTRACT=string
specifies a string for the abstract metadata of the package or file.
Restriction:You can use the ABSTRACT= option only with the ADD or OPEN arguments.
CLEAR
specifies that all files that were automatically added to the package will be removed from the location to which ODS wrote them.
Restriction:You can use the CLEAR option only with the CLOSE argument.
DESCRIPTION=string
specifies a string for the description metadata for the package or file.
Restriction:You can use the DESCRIPTION= option only with the ADD or OPEN arguments.
<(name)>
specifies the name of a package. Naming a package enables you to open more than one package at a time. Each destination can connect with any package by specifying the package name in the same way.
Restriction:The NAMEVALUE= option can be used only with the OPEN argument.
Requirements:You must place name directly after the PACKAGE keyword in the ODS PACKAGE statement.

name must be enclosed in parentheses.

NAMEVALUE="<name-1="value-1" . . . name-n="value-n">"
specifies a string of name/value pairs for the name/value metadata on the package or file.
Restriction:The NAMEVALUE= option can be used only with the ADD or OPEN arguments.
PATH="path-specification"
places the file or data set at the specified pathname within an ODS package.
Restriction:You can use the PATH= option only with the ADD argument.
Example:Use the following statement to add the Test.SAS file as plain text to the ODS package directory SAS:
ods package add file="test.sas" mimetype="text/plain" path="sas/";
TEMPLATE=
specifies the name of a package template to use.
Restriction:You can use the TEMPLATE= option only with the ADD or OPEN arguments.

Details

A package is a container for digital content that is generated or collected for delivery to a consumer. ODS packages allow ODS destinations to use the SAS Publishing Framework. An ODS package is an object that contains output files and data sets that are associated with any open ODS destinations. ODS packages hold the package metadata and track the output from any active destinations that connect to it. After the destinations are closed, the package can be published to any of the publish destinations. You can continue to use the package, or you can close it. A package remains active until explicitly closed.

Examples

Example 1: Creating an ODS Package

The following example creates a simple ODS package. The package is created in your default directory, if you do not specify a different directory.

Program

goptions dev=gif xpixels=480 ypixels=320;
ods package open;
ods html package;
 proc gplot data=sashelp.class;
     plot height*weight;
     by name;
 run;
 quit;
ods html close;
ods package publish archive properties
    (archive_name="SimpleExample.zip" archive_path="./");
ods package close;
ods html;

Program Description

Specify graphical options with the GOPTIONS statement.
goptions dev=gif xpixels=480 ypixels=320;
Open an ODS package and specify that HTML output be added to the package. The ODS PACKAGE statement opens an ODS package with no name. The PACKAGE option specified by the ODS HTML statement specifies that output from the HTML destination be added to the package.
ods package open;
ods html package;
Create graphical output with the GPLOT statement and close the HTML destination.
 proc gplot data=sashelp.class;
     plot height*weight;
     by name;
 run;
 quit;
ods html close;
Build the package and publish it to an archive. The PUBLISH option builds the ODS package. The ARCHIVE property publishes the package to the archive named SimpleExample.zip in the default directory.
ods package publish archive properties
    (archive_name="SimpleExample.zip" archive_path="./");
ods package close;
ods html;

Simple ODS Package

Contents of the compressed file, SimpleExample.zip

Example 2: Listing Package Contents with the ODS DOCUMENT Statement

In the following program, PROC DOCUMENT imports the archive SimpleExample.zip into a PROC DOCUMENT package named myPackage.You can then use PROC DOCUMENT to list the contents and details of the package.

Program

proc document name=archive;
   import archive="SimpleExample.zip" to myPackage;
   list/levels=all;
   run;
   dir myPackage;
   list 'sashtml.htm'n/details;
   run;
quit;

Program Description

Create an ODS document and import SimpleExample.zip.The DOCUMENT procedure creates the ODS document Archive. The IMPORT TO statement imports SimpleExample.zip into the package myPackage. The LIST statement lists all of the levels of Archive.
proc document name=archive;
   import archive="SimpleExample.zip" to myPackage;
   list/levels=all;
   run;
List the details of the file SasHtml.htm.The DIR statement changes the directory to myPackage. The LIST statement lists the details of SasHtml.htm.
   dir myPackage;
   list 'sashtml.htm'n/details;
   run;
quit;

Program Output

Listing of Work.Archive and Details of HTM File
Listing of Work.Archive

See Also

SAS Publishing Framework: Developer's Guide