In-Database Deployment Package for DB2

Prerequisites

SAS Foundation and the SAS/ACCESS Interface to DB2 must be installed before you install and configure the in-database deployment package for DB2.

Overview of the In-Database Deployment Package for DB2

This section describes how to install and configure the in-database deployment package for DB2 (SAS Formats Library for DB2 2.1).
The in-database deployment package for DB2 must be installed and configured before you can perform the following tasks:
  • use the %INDB2_PUBLISH_FORMATSformat publishing macro to create or publish the SAS_PUT() function and to create or publish user-defined formats as format functions inside the database.
  • use the %INDB2_PUBLISH_MODEL scoring publishing macro to create scoring model functions inside the database.
The format and scoring publishing macros are included in SAS/ACCESS Interface to DB2. For more information about using the format and scoring publishing macros, see the SAS In-Database Products: User's Guide.
The in-database deployment package for DB2 contains the SAS formats library and the precompiled binary files for two additional publishing macros.
The SAS formats library is a run-time library that is installed on your DB2 system so that the SAS scoring model functions and the SAS_PUT() function created in DB2 can access the routines within its run-time library.
The two publishing macros, %INDB2_PUBLISH_COMPILEUDF and %INDB2_PUBLISH_DELETEUDF, register utility functions in the database. The utility functions are called by the format and scoring publishing macros. You must run these two macros before you run the format and scoring publishing macros.

Function Publishing Process in DB2

To publish scoring model functions and the SAS_PUT() function on a DB2 server, the publishing macros perform the following tasks:
  • create and transfer the files to the DB2 environment
  • compile those source files into object files using the appropriate compiler for that system
  • link with the SAS formats library
After that, the publishing macros register the format and scoring model functions in DB2 with those object files. If an existing format or scoring model function is replaced, the publishing macros remove the obsolete object file upon successful compilation and publication of the new format or scoring model functions.
The publishing macros use a SAS FILENAME SFTP statement to transfer the format or scoring source files to the DB2 server. An SFTP statement offers a secure method of user validation and data transfer. The SAS FILENAME SFTP statement dynamically launches an SFTP or PSFTP executable, which creates an SSH client process that creates a secure connection to an OpenSSH Server. All conversation across this connection is encrypted, from user authentication to the data transfers.
Currently only the OpenSSH client and server on UNIX that supports protocol level SSH-2 and the PUTTY client on WINDOWS are supported. For more information about setting up the SSH software to enable the SAS SFTP to work, please see Setting Up SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method in SAS 9.2, located at http://support.sas.com/techsup/technote/ts800.pdf.

DB2 Installation and Configuration Steps

  1. Verify that you can use PSFTP from Windows to UNIX without being prompted for a password or cache.
    To do this, enter the following commands from the PSFTP prompt, where userid is the user ID that you want to log on as and machinename is the machine to which you want to log on.
    psftp> userid@machinename
    psftp> ls
  2. Install the SAS formats library and the binary files for the SAS_COMPILEUDF and SAS_DELETEUDF functions.
  3. Run the %INDB2_PUBLISH_COMPILEUDF macro to create the SAS_COMPILEUDF function.
  4. Run the %INDB2_PUBLISH_DELETEUDF macro to create the SAS_DELETEUDF function.
    For more information, see Running the %INDB2_PUBLISH_DELETEUDF Macro.
  5. If you plan to use SAS Model Manager with the SAS Scoring Accelerator for in-database scoring, perform the additional configuration tasks provided in Configurations for SAS Model Manager.

Installing the SAS Formats Library and Binary Files

Move the Files to DB2

The SAS formats library and the binary files for the SAS_COMPILEUDF and SAS_DELETEUDF functions are contained in a self-extracting TAR file. The TAR file is located in the SAS-install-directory/SASFormatsLibraryforDB2/2.1/DB2on<AIX | Linux64>/ directory.
You can use PSFTP, SFTP, or FTP to transfer the TAR file to the DB2 server to be unpacked and compiled.
The file does not have to be downloaded to a specific location, but you need to note where it is downloaded so that it can be executed as the DB2 instance owner at a later time. Choose the TAR file based on the UNIX platform that your DB2 server runs on:
AIX: acceldb2fmt-2.1-1_r64.sh
Linux(x86_64): acceldb2fmt-2.1-1_lax.sh
List the directory in UNIX to verify that the file has been moved.

Unpack the Files

After the TAR file has been transferred to the DB2 machine, follow these steps to unpack the files:
  1. Log in as the user who owns the DB2 instance from a secured shell, such as SSH.
  2. Use the following commands to unpack the appropriate TAR file. You must have the appropriate permissions to execute the script and write to the directory.
    $ cd path_to_tar_file
    $ ./tar_file
    path_to_tar_file is the location to which you copied the TAR file.
    tar_file is either acceldb2fmt-2.1-1_lax.sh or acceldb2fmt-2.1-1_r64.sh depending on your operating system.
    After this script is run and the files are unpacked, the content of the target directories should be similar to the following, depending on your operating system. Part of the directory path is shaded to emphasize the different target directories that are used.
    /path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1-1/bin/
       InstallAccelDB2Fmt.sh
    
    /path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1-1/bin/CopySASFiles.sh
    
    /path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1-1/lib/SAS_CompileUDF
    
    /path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1-1/lib/SAS_DeleteUDF
    
    /path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1-1/lib/libjazxfbrs.so
    
    /path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1 ->2.1-1
  3. Use the following command to place the files in the DB2 instance:
    $ path_to_tar_file/SAS/SASFormatsLibraryForDB2/2.1-1/bin/
       CopySASFiles.sh db2path/sqllib
    
    db2path/sqllib is the path to the sqllib directory of the DB2 instance that you want to use.
    After this script is run and the files are copied, the target directory should look similar to this.
    db2path/sqllib/function/SAS/SAS_CompileUDF
    db2path/sqllib/function/SAS/SAS_DeleteUDF
    db2path/sqllib/function/SAS/libjazxfbrs.so
    
    Note: If the SAS_CompileUDF, SAS_DeleteUDF, and libjazxfbrs.so files currently exist under the target directory, you must rename the existing files before you run the CopySASFiles.sh command. Otherwise, the CopySASFiles.sh command does not work, and you get a "Text file is busy" message for each of the three files.
  4. Use the DB2SET command to tell DB2 where to find the 64-bit formats library.
    The DB2 instance owner must run this command for it to be successful. Note that this is similar to setting a UNIX system environment variable using the UNIX EXPORT or SETENV commands. DB2SET registers the environment variable within DB2 only for the specified database server.
    Before running the DB2SET command, ensure that the DB2 environment is set up correctly. To source the DB2 environment, run the following command.
    $ db2path/sqllib . ./db2profile
    Now, run the DB2SET command.
    $ db2set DB2LIBPATH=db2path/sqllib/function/SAS
    db2path/sqllib is the path to the sqllib directory of the DB2 instance that you want to use.
  5. To verify that DB2LIBPATH was set appropriately, run the DB2SET command without any parameters as follows.
    $ db2path/sqllib/adm/db2set
    The correct path should be listed if it was set correctly.

Running the %INDB2_PUBLISH_COMPILEUDF Macro

Overview of the %INDB2_PUBLISH_COMPILEUDF Macro

The %INDB2_PUBLISH_COMPILEUDF macro publishes the following components to the SASLIB schema in a DB2 database:
  • SAS_COMPILEUDF function
    The SAS_COMPILEUDF function facilitates the %INDB2_PUBLISH_FORMATS format publishing macro and the %INDB2_PUBLISH_MODEL scoring publishing macro. The SAS_COMPILEUDF function performs the following tasks:
    • compiles the format and scoring model source files into object files. This compilation occurs through the SQL interface using an appropriate compiler for the system.
    • links with the SAS formats library that is needed for format and scoring model publishing.
    • copies the object files to the db2path/sqllib/function/SAS directory. You specify the value of db2path in the %INDB2_PUBLISH_COMPILEUDF macro syntax.
  • SASUDF_DB2PATH and SASUDF_COMPILER_PATH global variables
    The SASUDF_DB2PATH and the SASUDF_COMPILER_PATH global variables are used when you publish the format and scoring model functions.
You have to run the %INDB2_PUBLISH_COMPILEUDF macro only one time in a given database.
The SAS_COMPILEUDF function must be published before you run the %INDB2_PUBLISH_DELETEUDF macro, the %INDB2_PUBLISH_FORMATS macro, and the %INDB2_PUBLISH_MODEL macro. Otherwise, these macros fail.
Note: To publish the SAS_COMPILEUDF function, you must have the appropriate DB2 user permissions to create and execute this function in the SASLIB schema and in the specified database. For more information, see DB2 Permissions.

%INDB2_PUBLISH_COMPILEUDF Macro Run Process

To run the %INDB2_PUBLISH_COMPILEUDF macro, follow these steps:
  1. Create a SASLIB schema in the database where the SAS_COMPILEUDF function is published.
    The SASLIB schema is used when publishing the %INDB2_PUBLISH_COMPILEUDF macro for DB2 in-database processing.
    You specify that database in the DATABASE argument of the %INDB2_PUBLISH_COMPILEUDF macro. For more information, see %INDB2_PUBLISH_COMPILEUDF Macro Syntax.
    The SASLIB schema will contain the SAS_COMPILEUDF and SAS_DELETEUDF functions and the SASUDF_DB2PATH and SASUDF_COMPILER_PATH global variables.
  2. Start SAS 9.3 and submit the following commands in the Enhanced Editor or Program Editor:
    %indb2pc;
    %let indconn = server=yourserver user=youruserid password=yourpwd
       database=yourdb schema=saslib;
    
    For more information, see %INDB2PC Macro and INDCONN Macro Variable.
  3. Run the %INDB2_PUBLISH_COMPILEUDF macro. For more information, see %INDB2_PUBLISH_COMPILEUDF Macro Syntax.
You can verify that the SAS_COMPILEUDF function and global variables have been published successfully. For more information, see Validating the Publishing of SAS_COMPILEUDF and SAS_DELETEUDF Functions and Global Variables.
After the SAS_COMPILEUDF function is published, run the %INDB2_PUBLISH_DELETEUDF publishing macro to create the SAS_DELETEUDF function. For more information, see Running the %INDB2_PUBLISH_DELETEUDF Macro.

%INDB2PC Macro

The %INDB2PC macro is an autocall library that initializes the %INDB2_PUBLISH_COMPILEUDF macro.

INDCONN Macro Variable

The INDCONN macro variable provides the credentials to make a connection to DB2. You must specify the server, user, password, and database information to access the machine on which you have installed the DB2 database. You must assign the INDCONN macro variable before the %INDB2_PUBLISH_COMPILEUDF macro is invoked.
The value of the INDCONN macro variable for the %INDB2_PUBLISH_COMPILEUDF macro has this format.
SERVER=server USER=userid PASSWORD=password
DATABASE=database <SCHEMA=SASLIB>
SERVER=server
specifies the DB2 server name or the IP address of the server host. If the server name contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.
Requirement: The name must be consistent with the way that the host name was cached when PSFTP server was run from the command window. If the full server name was cached, you must use the full server name in the SERVER argument. If the short server name was cached, you must use the short server name. For example, if the long name, disk3295.unx.comp.com, is used when PSFTP was run, then server=disk3295.unx.comp.com must be specified. If the short name, disk3295, was used, then server=disk3295 must be specified. For more information, see DB2 Installation and Configuration Steps.
USER=userid
specifies the DB2 user name (also called the user ID) that is used to connect to the database. If the user name contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.
PASSWORD=password
specifies the password that is associated with your DB2 user ID. If the password contains spaces or nonalphabetic characters, you must enclose it in quotation marks.
Tip:You can use only PASSWORD=, PASS=, or PW= for the password argument. PWD= is not supported and causes an error.
DATABASE=database
specifies the DB2 database that contains the tables and views that you want to access. If the database name contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.
Requirement:The SAS_COMPILEUDF function is created as a Unicode function. If the database is not a Unicode database, then the alternate collating sequence must be configured to use identity_16bit.
SCHEMA=SASLIB
specifies SASLIB as the schema name.
Default:SASLIB
Restriction: The SAS_COMPILEUDF function and the two global variables (SASUDF_DB2PATH and SASUDF_COMPILER_PATH) are published to the SASLIB schema in the specified database. If a value other than SASLIB is used, it will be ignored.
Requirement:The SASLIB schema must be created before publishing the SAS_COMPILEUDF and SAS_DELETEUDF functions.

%INDB2_PUBLISH_COMPILEUDF Macro Syntax

%INDB2_PUBLISH_COMPILEUDF(
DB2PATH=db2path/sqllib
, COMPILER_PATH=compiler-path-directory
<, DATABASE=database-name>
<, ACTION=CREATE | REPLACE | DROP>
<, OBJNAME=object-file-name>
<, OUTDIR=diagnostic-output-directory>
);
Arguments
DB2PATH=db2path/sqllib
specifies the parent directory that contains the function/SAS subdirectory, where all the object files are stored and defines the SASUDF_DB2PATH global variable that is used when publishing the format and scoring model functions.
Interaction:db2path should be the same path as the path that was specified during the installation of the SAS_COMPILEUDF binary file. For more information, see Step 3 in Unpack the Files.
Tip:The SASUDF_DB2PATH global variable is defined in the SASLIB schema under the specified database name.
COMPILER_PATH=compiler-path-directory
specifies the path to the location of the compiler that compiles the source files and defines the SASUDF_COMPILER_PATH global variable that is used when publishing the format and scoring model functions.
Tip: The SASUDF_COMPILER_PATH global variable is defined in the SASLIB schema under the specified database name. The xlc compiler should be used for AIX, and the gcc compiler should be used for Linux.
DATABASE=database-name
specifies the name of a DB2 database to which the SAS_COMPILEUDF function is published.
Interaction: The database that you specify in the DATABASE= argument takes precedence over the database that you specify in the INDCONN macro variable. For more information, see %INDB2_PUBLISH_COMPILEUDF Macro Run Process.
ACTION=CREATE | REPLACE | DROP
specifies that the macro performs one of the following actions:
CREATE
creates a new SAS_COMPILEUDF function.
REPLACE
overwrites the current SAS_COMPILEUDF function, if a SAS_COMPILEUDF function by the same name is already registered, or creates a new SAS_COMPILEUDF function if one is not registered.
DROP
causes the SAS_COMPILEUDF function to be dropped from the DB2 database.
Default:CREATE
Tip:If the SAS_COMPILEUDF function was published previously and you now specify ACTION=CREATE, you receive warning messages from DB2. If the SAS_COMPILEUDF function was published previously and you specify ACTION=REPLACE, no warnings are issued.
OBJNAME=object-file-name
specifies the object filename that the publishing macro uses to register the SAS_COMPILEUDF function. The object filename is a file system reference to a specific object file, and the value entered for OBJNAME must match the name as it exists in the file system. For example, SAS_CompileUDF is mixed case.
Default:SAS_CompileUDF
Interaction:If the SAS_COMPILEUDF function is updated, you might want to rename the object file to avoid stopping and restarting the database. If so, the SAS_COMPILEUDF function needs to be reregistered with the new object filename.
OUTDIR=output-directory
specifies a directory that contains diagnostic files.
Tip:Files that are produced include an event log that contains detailed information about the success or failure of the publishing process.

Running the %INDB2_PUBLISH_DELETEUDF Macro

Overview of the %INDB2_PUBLISH_DELETEUDF Macro

The %INDB2_PUBLISH_DELETEUDF macro publishes the SAS_DELETEUDF function in the SASLIB schema of a DB2 database. The SAS_DELETEUDF function facilitates the %INDB2_PUBLISH_FORMATS format publishing macro and the %INDB2_PUBLISH_MODEL scoring publishing macro. The SAS_DELETEUDF function removes existing object files when the format or scoring publishing macro registers new ones by the same name.
You have to run the %INDB2_PUBLISH_DELETEUDF macro only one time in a given database.
The SAS_COMPILEUDF function must be published before you run the %INDB2_PUBLISH_DELETEUDF macro, the %INDB2_PUBLISH_FORMATS macro, and the %INDB2_PUBLISH_MODEL macro. Otherwise, these macros fail.
Note: To publish the SAS_DELETEUDF function, you must have the appropriate DB2 user permissions to create and execute this function in the SASLIB schema and specified database. For more information, see DB2 Permissions.

%INDB2_PUBLISH_DELETEUDF Macro Run Process

To run the %INDB2_PUBLISH_DELETEUDF macro, follow these steps:
  1. Ensure that you have created a SASLIB schema in the database where the SAS_DELETEUDF function is published.
    The SASLIB schema is used when publishing the %INDB2_PUBLISH_DELETEUDF macro for DB2 in-database processing.
    The SASLIB schema should have been created when you ran the %INDB2_PUBLISH_COMPILEUDF macro to create the SAS_COMPILEUDF function. The SASLIB schema contains the SAS_COMPILEUDF and SAS_DELETEUDF functions and the SASUDF_DB2PATH and SASUDF_COMPILER_PATH global variables.
    The SAS_COMPILEUDF function must be published before you run the %INDB2_PUBLISH_DELETEUDF macro. The SAS_COMPILEUDF and SAS_DELETEUDF functions must be published to the SASLIB schema in the same database. For more information about creating the SASLIB schema, see %INDB2_PUBLISH_COMPILEUDF Macro Run Process.
  2. Start SAS 9.3 and submit the following commands in the Enhanced Editor or Program Editor.
    %indb2pd;
    %let indconn = server=yourserver user=youruserid password=yourpwd
       database=yourdb schema=saslib;
    
    For more information, see %INDB2PD Macro and INDCONN Macro Variable.
  3. Run the %INDB2_PUBLISH_DELETEUDF macro. For more information, see %INDB2_PUBLISH_DELETEUDF Macro Syntax.
You can verify that the function has been published successfully. For more information, see Validating the Publishing of SAS_COMPILEUDF and SAS_DELETEUDF Functions and Global Variables.
After the SAS_DELETEUDF function is published, the %INDB2_PUBLISH_FORMATS and the %INDB2_PUBLISH_MODEL macros can be run to publish the format and scoring model functions.

%INDB2PD Macro

The %INDB2PD macro is an autocall library that initializes the %INDB2_PUBLISH_DELETEUDF macro.

INDCONN Macro Variable

The INDCONN macro variable provides the credentials to make a connection to DB2. You must specify the server, user, password, and database information to access the machine on which you have installed the DB2 database. You must assign the INDCONN macro variable before the %INDB2_PUBLISH_DELETEUDF macro is invoked.
The value of the INDCONN macro variable for the %INDB2_PUBLISH_DELETEUDF macro has this format.
SERVER=server USER=userid PASSWORD=password
DATABASE=database <SCHEMA=SASLIB>
SERVER=server
specifies the DB2 server name or the IP address of the server host. If the server name contains spaces or nonalphanumeric characters, you must enclose the name in quotation marks.
Requirement: The name must be consistent with the way that the host name was cached when PSFTP server was run from the command window. If the full server name was cached, use the full server name in the SERVER argument. If the short server name was cached, use the short server name. For example, if the long name, disk3295.unx.comp.com, is used when PSFTP was run, then server=disk3295.unx.comp.com must be specified. If the short name, disk3295, was used, then server=disk3295 must be specified. For more information, see DB2 Installation and Configuration Steps.
USER=userid
specifies the DB2 user name (also called the user ID) that is used to connect to the database. If the user name contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.
PASSWORD=password
specifies the password that is associated with your DB2 user ID. If the password contains spaces or nonalphabetic characters, you must enclose it in quotation marks.
Tip:You can use only PASSWORD=, PASS=, or PW= for the password argument. PWD= is not supported and causes errors.
DATABASE=database
specifies the DB2 database that contains the tables and views that you want to access. If the database name contains spaces or nonalphanumeric characters, you must enclose the name in quotation marks.
SCHEMA=SASLIB
specifies SASLIB as the schema name.
Default:SASLIB
Restriction:The SAS_DELETEUDF function is published to the SASLIB schema in the specified database. If a value other than SASLIB is used, it will be ignored.
Requirement:The SASLIB schema must be created before publishing the SAS_COMPILEUDF and SAS_DELETEUDF functions.

%INDB2_PUBLISH_DELETEUDF Macro Syntax

%INDB2_PUBLISH_DELETEUDF (
<DATABASE=database-name>
<, ACTION=CREATE | REPLACE | DROP>
<, OUTDIR=diagnostic-output-directory>
);
Arguments
DATABASE=database-name
specifies the name of a DB2 database to which the SAS_DELETEUDF function is published.
Interaction:The database that you specify in the DATABASE argument takes precedence over the database that you specify in the INDCONN macro variable. For more information, see Running the %INDB2_PUBLISH_DELETEUDF Macro.
ACTION=CREATE | REPLACE | DROP
specifies that the macro performs one of the following actions:
CREATE
creates a new SAS_DELETEUDF function.
REPLACE
overwrites the current SAS_DELETEUDF function, if a SAS_DELETEUDF function by the same name is already registered, or creates a new SAS_DELETEUDF function if one is not registered.
DROP
causes the SAS_DELETEUDF function to be dropped from the DB2 database.
Default: CREATE
Tip:If the SAS_DELTEUDF function was published previously and you specify ACTION=CREATE, you receive warning messages from DB2. If the SAS_DELETEUDF function was published previously and you specify ACTION=REPLACE, no warnings are issued.
OUTDIR=diagnostic-output-directory
specifies a directory that contains diagnostic files.
Tip:Files that are produced include an event log that contains detailed information about the success or failure of the publishing process.

Validating the Publishing of SAS_COMPILEUDF and SAS_DELETEUDF Functions and Global Variables

To validate that the global variables are created properly, follow these steps.
  1. Connect to your DB2 database using Command Line Processor (CLP).
  2. Enter the following command.
    values(saslib.sasudf_compiler_path)
    You should receive a result similar to one of the following.
    /usr/vac/bin      /* on AIX */
    /usr/bin        /* on Linux */
    
  3. Open a UNIX window; validate that the xlc compiler (on AIX) or gcc compiler (on Linux) is in the path that you received as a result.
  4. Connect to DB2 using CLP and enter the following command.
    values(saslib.sasudf_db2path)
    You should receive a result similar to the following.
    /users/db2v9/sqllib
    In this example, /users/db2v9 is the value of db2path that was specified during installation and /users/db2v9/sqllib is where the SAS_COMPILEUDF function was published.
  5. Open a UNIX window; validate that sasudf_db2path is defined as the path that you received as a result.
  6. Connect to DB2 using CLP and enter the following command.
    select funcname, implementation from syscat.functions where
       funcschema='SASLIB'
    
    You should receive a result similar to the following.
    FUNCNAME                         IMPLEMENTATION
    -------------------------------------------------------------
    SAS_DELETEUDF
    /users/db2v9/sqllib/function/SAS/SAS_DeleteUDF!SAS_DeleteUDF
    SAS_COMPILEUDF
    /users/db2v9/sqllib/function/SAS/SAS_CompileUDF!SAS_CompileUDF
    
  7. Open a UNIX window; validate that the SAS_COMPILEUDF and SAS_DELETEUDF functions are installed in the paths that you received as results.
  8. To validate that the SAS_COMPILEUDF and SAS_DELETEUDF functions were built properly for the server box, enter an LDD command from the UNIX command line similar to this one.
    $ ldd db2path/sqllib/function/SAS/SAS_CompileUDF
    The results should look similar to the following, depending on your operating system.
    SAS_CompileUDF needs:
         /usr/lib/libc.a(shr_64.o)
         /unix
         /usr/lib/libcrypt.a(shr_64.o)
    

DB2 Permissions

There are two sets of permissions involved with the in-database software.
The first set of permissions is needed by the person who publishes the SAS_COMPILEUDF and SAS_DELETEUDF functions and creates the SASUDF_COMPILER_PATH and SASUDF_DB2PATH global variables.
These permissions must be granted before the %INDB2_PUBLISH_COMPILEUDF and %INDB2_PUBLISH_DELETEUDF macros are run. Without these permissions, running these macros fails.
The following table summarizes the permissions that are needed by the person who publishes the functions and creates the global variables.
Permission Needed
Authority Required to Grant Permission
Examples
CREATEIN permission for the SASLIB schema in which the SAS_COMPILEUDF and SAS_DELETEUDF functions are published and the SASUDF_COMPILER_PATH and SASUDF_DB2PATH global variables are defined
System Administrator or Database Administrator
Note: If you have SYSADM or DBADM authority or are the DB2 instance owner, then you have these permissions. Otherwise, contact your database administrator to obtain these permissions.
GRANT CREATEIN ON SCHEMA SASLIB 
TO compiledeletepublisheruserid
CREATE_EXTERNAL_ROUTINE permission to the database in which the SAS_COMPILEUDF and SAS_DELETEUDF functions are published
GRANT CREATE_EXTERNAL_ROUTINE ON 
DATABASE TO 
compiledeletepublisheruserid
The second set of permissions is needed by the person who publishes the format or scoring model functions. The person who publishes the format or scoring model functions is not necessarily the same person who publishes the SAS_COMPILEUDF and SAS_DELETEUDF functions and creates the SASUDF_COMPILER_PATH and SASUDF_DB2PATH global variables. These permissions are most likely needed by the format publishing or scoring model developer. Without these permissions, the publishing of the format or scoring model functions fails.
Note: Permissions must be granted for every format or scoring model publisher and for each database that the format or scoring model publishing uses. Therefore, you might need to grant these permissions multiple times.
After the DB2 permissions have been set appropriately, the format or scoring publishing macro should be called to register the formats or scoring model functions.
The following table summarizes the permissions that are needed by the person who publishes the format or scoring model functions.
Permission Needed
Authority Required to Grant Permission
Examples
EXECUTE permission for functions that have been published.
This enables the person who publishes the formats or scoring model functions to execute the SAS_COMPILEUDF and SAS_DELETEUDF functions.
System Administrator or Database Administrator
Note: If you have SYSADM or DBADM authority, then you have these permissions. Otherwise, contact your database administrator to obtain these permissions.
GRANT EXECUTE ON FUNCTION 
SASLIB.* TO 
scoringorfmtpublisherid
CREATE_EXTERNAL_ROUTINE permission to the database to create format or scoring model functions
GRANT CREATE_EXTERNAL_ROUTINE ON 
DATABASE TO 
scoringorfmtpublisherid
CREATE_NOT_FENCED_ROUTINE permission to create format or scoring model functions that are not fenced
GRANT CREATE_NOT_FENCED_ROUTINE 
ON DATABASE TO 
scoringorfmtpublisherid
CREATEIN permission for the schema in which the format or scoring model functions are published if the default schema (SASLIB) is not used
GRANT CREATEIN ON SCHEMA 
scoringschema TO 
scoringorfmtpublisherid
READ permission to read the SASUDF_COMPILER_PATH and SASUDF_DB2PATH global variables
Note: The person who ran the %INDB2_PUBLISH_COMPILEUDF macro has these READ permissions and does not need to grant them to himself or herself again.
Person who ran the %INDB2_PUBLISH_COMPILEUDF macro
Note: For security reasons, only the user who created these variables has the permission to grant READ permission to other users. This is true even for the user with administrator permissions such as the DB2 instance owner.
GRANT READ ON VARIABLE 
SASLIB.SASUDF_DB2PATH TO 
scoringorfmtpublisherid

GRANT READ ON VARIABLE 
SASLIB.SASUDF_COMPILER_PATH
TO scoringorfmtpublisherid
Note: If you plan to use SAS Model Manager with the SAS Scoring Accelerator for in-database scoring, additional permissions are required. For more information, see Configurations for SAS Model Manager.

Documentation for Publishing SAS Formats or Scoring Models in DB2

For information about how to publish SAS formats or scoring models, see the SAS In-Database Products: User's Guide located at http://support.sas.com/documentation/onlinedoc/indbtech/index.html.