You can access routines that reside
in external dynamic link libraries (DLLs) by using the SAS MODULE
family of functions within a DATA step or SCL. This action lets you
access DLLs that you create or purchase; you can even access operating
system DLLs.
To access an external
DLL, you must know:
-
-
the function name or ordinal
-
a description of the function's
arguments
-
a description of the return code.
CAUTION:
Only experienced
programmers should access external DLLs.
When you access an
external DLL, you are passing control of your computer from SAS to
the DLL function. If done improperly, or if the DLL function is unreliable,
you might lose data or have to reset your computer (or both).
The general steps for
accessing an external DLL routine are:
-
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.
-
Use the FILENAME statement
to assign the SASCBTBL fileref to the attribute file that you created.
-
In a DATA step or SCL
code, use 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.)
Note: The MODULE routines can be
a flexible and powerful tool, especially when used with the SASCBTBL
file, SAS formats and informats, and other SAS routines. As such,
you should be extremely careful when invoking external routines; if
done improperly, you might lose data or have to reset your computer.