Overview of Dynamic Link Libraries in SAS

Dynamic link libraries (DLLs) are executable files that contain one or more routines written in any of several programming languages. DLLs are a mechanism for storing useful routines that might be needed by many applications. When an application needs a routine that resides in a DLL, it loads the DLL, invokes the routine, and unloads the DLL upon completion. SAS provides routines and functions that let you invoke these external routines from within SAS. You can access the DLL 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 DLL. This documentation refers to the MODULE family of call routines and functions generically as the MODULE functions.
These are general steps for accessing an external DLL routine:
  1. Create a text file that describes the DLL routine that you want to access, including the arguments that it expects and the values that 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 that you created.
  3. In a DATA step or SCL code, use a call routine or function (MODULE, MODULEN, or MODULEC) to invoke the DLL routine. The specific function that 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 MODULE Function: Windows.
CAUTION:
Only experienced programmers should access external DLLs.
By accessing a function in an external DLL, 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).