Previous Page | Next Page

Accessing Shared Executable Libraries from SAS

Overview of Shared Libraries in SAS


What Is a Shared Library?

Shared libraries in UNIX are libraries that contain executable programs that are written in any of several programming languages. In UNIX, the names of these programs typically end with a .so or .sl extension. However, they are not constrained to this naming convention.

Shared libraries are a mechanism for storing useful routines that might be needed by multiple applications. When an application needs a routine that resides in an external shared library, it loads the shared library, invokes the routine, and unloads the shared library upon completion.


Invoking Shared Libraries from within SAS

SAS provides routines and functions that let you invoke these external routines from within SAS. You can access the shared library 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, and MODULEC), as well as the SAS/IML functions and CALL routines (including MODULEIC, MODULEIN, and MODULEI), to invoke a routine that resides in a shared library. This documentation refers to the MODULE family of CALL routines and functions generically as the MODULE function.

For information about MODULE, MODULEN, and MODULEC, see the SAS Language Reference: Dictionary. For information about MODULEIC, MODULEIN, and MODULEI, see the SAS/IML User's Guide.


Steps for Accessing an External Shared Library

Use the following steps to access an external shared library routine:

  1. Create a text file that describes the shared library 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 library 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 functions are described in CALL MODULE Routine: UNIX.

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

By accessing a function in a shared library, you transfer processing control to the external function. If done improperly, or if the external function is not reliable, you might lose data, get unreliable results, or receive severe errors.  [cautionend]

Previous Page | Next Page | Top of Page