Language Reference


PACKAGE LOAD Statement

(Experimental)

  • PACKAGE LOAD packagename<(collection <VERSION=version> )> …;

The PACKAGE LOAD statement is experimental in SAS/IML 14.1. The PACKAGE LOAD statement executes the package source files. Usually the source files define SAS/IML modules. However, a package might also define SAS/IML matrices, create data sets, define macro variables, or carry out a computation.

You must specify the following argument:

packagename

specifies the name of the package. You can specify multiple names in a single statement.

You can also specify the following options in parentheses:

collection

requests that only the specified collection be searched for the file to be executed. Valid values for collection are PRIVATE, PUBLIC, and SYSTEM. For more information about collections, see the PACKAGE statement .

VERSION=version

specifies the minimum required version number for loading a package. A version number is a text string that contains up to four numbers that are separated by decimal points. For example, valid values are "1.0", "2.7.1", and "3.1.4.1". When the PACKAGE LOAD statement finds a specified package, it checks the package version. If the package version is greater than or equal to version, the package is loaded. Otherwise, the statement displays an error message.

The following statement loads the AboveBelow package, which is installed in the SYSTEM collection:

package load AboveBelow;

The PACKAGE LOAD statement reads the info.txt file and uses the SourceFiles keyword to determine which files contain the source code for the package. (For more information about the info.txt file, see the section Step 2: Create the Package Information File.) The statement executes the specified files, which are located in the source directory of the package’s root directory. For the AboveBelow package, the PACKAGE LOAD statement defines several SAS/IML modules. The SAS Log window indicates that new modules were defined.

As a second example, the following PACKAGE LOAD statement loads a package called Pkg1 from the PUBLIC collection. The load succeeds if the installed version of the package is greater than or equal to version 1.2, but it fails if the installed version of the package is less than 1.2. For example, the load succeeds if the installed version is 1.2, 1.3, or 2.1. The load fails if the installed version is 1.1.

package load Pkg1(public version="1.2");

The PACKAGE LOAD statement is similar to the EXECUTEFILE subroutine but differs in the following ways:

  • The PACKAGE LOAD statement can execute multiple files. The EXECUTEFILE subroutine executes a single file.

  • The PACKAGE LOAD statement keeps track of which packages have been loaded. A subsequent PACKAGE LOAD statement does not reread and rerun the package source files. In contrast, the EXECUTEFILE subroutine rereads and reruns the file every time it is called.

The IMLPlus language in the SAS/IML Studio application executes the PACKAGE LOAD statement at parse time. That is, SAS/IML Studio reads the source files and defines the modules before it executes any statements.