Previous Page | Next Page

Accessing External Shared Images from SAS

Overview of Shared Images in SAS


What is a Shared Image?

Shared images are executable files that contain one or more routines written in any of several programming languages. A shared image is created when you use the /SHAREABLE qualifier with the LINK command. Shared images are a mechanism for storing useful routines that might be needed by many applications. When an application needs a routine that resides in a shared image, it loads the shared image and invokes the routine.


Invoking Shared Images from within SAS

SAS provides routines and functions that let you invoke these external routines from within SAS. You can access the shared image routines from the DATA step, the IML procedure, and SCL code. You use the MODULE family of SAS call routines and functions (including MODULE, MODULEN, MODULEC, MODULEI, MODULEIN, and MODULEIC) to invoke a routine that resides in an external shared image. This documentation refers to the MODULE family of call routines and functions generically as the MODULE function.


Steps for Accessing an External Shared Image

The following are the steps for accessing an external shared image routine:

  1. Create a text file that describes the shared image routine you want to access, including the arguments it expects and the values it returns (if any). This attribute file must be in a special format, as described in The SASCBTBL Attribute Table.

  2. Use the FILENAME statement to assign the SASCBTBL fileref to the attribute file you created.

  3. In a DATA step or SCL code, use a call routine or function (MODULE, MODULEN, or MODULEC) to invoke the shared image routine. The specific function you use depends on the type of expected return value (none, numeric, or character). (You can also use MODULEI, MODULEIN, or MODULEIC within a PROC IML step.) The MODULE function is described in MODULE Function: OpenVMS.

CAUTION:
Only experienced programmers should access external routines in shared images.

By accessing a function in an external shared image, you transfer processing control to the external function. If done improperly, or if the external function is not reliable, you might lose data or have to reset your computer (or both).  [cautionend]

Previous Page | Next Page | Top of Page