Running the %INDNZ_PUBLISH_MODEL Macro

%INDNZ_PUBLISH_MODEL Macro Run Process

To run the %INDNZ_PUBLISH_MODEL macro, complete the following steps:
  1. Create a scoring model using SAS Enterprise Miner.
  2. Use the SAS Enterprise Miner Score Code Export node to create a score output directory and populate the directory with the score.sas file, the score.xml file, and, if needed, the format catalog.
  3. Start SAS 9.2 and submit the following commands in the Program Editor or Enhanced Editor:
    %indnzpm;
    %let indconn = server=myserver user=myuserid password=XXXX database=mydb;
    
    The %INDNZPM macro searches the autocall library for the indnzpm.sas file. The indnzpm.sas file contains all the macro definitions that are used in conjunction with the %INDNZ_PUBLISH_MODEL macro. The indnzpm.sas file should be in one of the directories listed in the SASAUTOS= system option in your configuration file. If the indnzpm.sas file is not present, the %INDNZPM macro call (%INDNZPM; statement) issues the following message:
    macro indnzpm not defined
    The INDCONN macro variable is used to provide credentials to connect to Netezza. You must specify server, user, password, and database information to access the machine on which you have installed the Netezza data warehouse. You must assign the INDCONN macro variable before the %INDNZ_PUBLISH_MODEL macro is invoked.
    Here is the syntax for the value of the INDCONN macro variable for the %INDNZ_PUBLISH_MODEL macro:
    SERVER=server USER=user PASSWORD=password DATABASE=database
    Tip
    You can use only PASSWORD= or PW= for the password argument. Other aliases, such as PASS= or PWD=, are not supported and will cause an error to occur.
    Tip
    The INDCONN macro variable is not passed as an argument to the %INDNZ_PUBLISH_MODEL macro. This information can be concealed in your SAS job. For example, you can place it in an autoexec file and apply permissions to the file so others cannot access the user credentials.
  4. Run the %INDNZ_PUBLISH_MODEL macro. For more information, see %INDNZ_PUBLISH_MODEL Macro Syntax.
    Messages are written to the SAS log that indicate the success or failure of the creation of the scoring functions.
Note: The %INDNZ_PUBLISH_JAZLIB macro and the %INDNZ_PUBLISH_COMPILEUDF macro, if needed, must be run before you can publish your scoring models. Otherwise, the %INDNZ_PUBLISH_MODEL macro will fail. These macros are typically run by your system or database administrator. For more information about these macros, see SAS In-Database Products: Administrator's Guide.

%INDNZ_PUBLISH_MODEL Macro Syntax

%INDNZ_PUBLISH_MODEL
(DIR=input-directory-path, MODELNAME=name
<, DATASTEP=score-program-filename>
<, XML=xml-filename>
<, DATABASE=database-name>
<, DBCOMPILE=database-name>
<, DBJAZLIB=database-name>
<, FMTCAT=format-catalog-filename>
<, ACTION=CREATE | REPLACE | DROP >
<, IDCASE=UPPERCASE | LOWERCASE >
<, OUTDIR=diagnostic-output-directory>
);
Note: Do not enclose variable arguments in single or double quotation marks. This causes the %INDNZ_PUBLISH_MODEL macro to fail.
Arguments
DIR=input-directory-path
specifies the directory where the scoring model program, the properties file, and the format catalog are located.
This is the directory that is created by the SAS Enterprise Miner Score Code Export node. This directory contains the score.sas file, the score.xml file, and, if user-defined formats were used, the format catalog.
Requirement: You must use a fully qualified pathname.
Interaction: If you do not use the default directory that is created by SAS Enterprise Miner, you must specify the DATASTEP=, XML=, and, if needed, FMTCAT= arguments.
MODELNAME=name
specifies the name that is prepended to each output function to ensure that each scoring function name is unique on the Netezza database.
Restriction: The scoring function name is a combination of the model and output variable names. A scoring function name cannot exceed 128 characters. For more information, see Scoring Function Names.
Requirement: The model name must be a valid SAS name that is ten characters or fewer. For more information about valid SAS names, see the topic on rules for words and names in SAS 9.2 Language Reference: Concepts.
Interaction: Only the EM_ output variables are published as Netezza scoring functions. For more information about the EM_ output variables, see Fixed Variable Names and Scoring Function Names.
DATASTEP=score-program-filename
specifies the name of the scoring model program file that was created by using the SAS Enterprise Miner Score Code Export node.
Default: score.sas
Restriction: Only DATA step programs that are produced by the SAS Enterprise Miner Score Code Export node can be used.
Interaction: If you use the default score.sas file that is created by the SAS Enterprise Miner Score Code Export node, you do not need to specify the DATASTEP= argument.
XML=xml-filename
specifies the name of the properties XML file that was created by the SAS Enterprise Miner Score Code Export node.
Default: score.xml
Restriction: Only XML files that are produced by the SAS Enterprise Miner Score Code Export node can be used.
Restriction: The maximum number of output variables is 128.
Interaction: If you use the default score.xml file that is created by the SAS Enterprise Miner Score Code Export node, you do not need to specify the XML= argument.
DATABASE=database-name
specifies the name of a Netezza database to which the scoring functions and formats are published.
Tip
You can publish the scoring functions and formats to a shared database where other users can access them.
Interaction: The database that is specified by the DATABASE argument takes precedence over the database that you specify in the INDCONN macro variable. For more information, see %INDNZ_PUBLISH_MODEL Macro Run Process.
DBCOMPILE=database-name
specifies the name of the database where the SAS_COMPILEUDF function is published.
Default: SASLIB
See Also: For more information about publishing the SAS_COMPILEUDF function, see the SAS In-Database Products: Administrator's Guide.
DBJAZLIB=database-name
specifies the name of the database where the SAS 9.2 Formats Library for Netezza is published.
Default: SASLIB
Restriction:This argument is supported only for TwinFin systems.
FMTCAT=format-catalog-filename
specifies the name of the format catalog file that contains all user-defined formats that were created by the FORMAT procedure and that are referenced in the DATA step scoring model program.
Restriction: Only format catalog files that are produced by the SAS Enterprise Miner Score Code Export node can be used.
Interaction: If you use the default format catalog that is created by the SAS Enterprise Miner Score Code Export node, you do not need to specify the FMTCAT= argument.
Interaction: If you do not use the default catalog name (FORMATS) or the default library (WORK or LIBRARY) when you create user-defined formats, you must use the FMTSEARCH system option to specify the location of the format catalog. For more information, see PROC FORMAT in the Base SAS 9.2 Procedures Guide.
ACTION=CREATE | REPLACE | DROP
specifies one of the following actions that the macro performs:
CREATE creates a new function.
REPLACE overwrites the current function, if a function by the same name is already registered.
DROP causes all functions for this model to be dropped from the Netezza database.
Default: CREATE
Tip
If the function was published previously and you specify ACTION=CREATE or REPLACE, no warning is issued. Also, if you specify ACTION=DROP and the function does not exist, no warning is issued.
IDCASE= UPPERCASE | LOWERCASE
specifies whether the variable names in the generated sample SQL code (SampleSQL.txt) appear in uppercase or lowercase characters.
Default: UPPERCASE
See: Using the Scoring Functions for more information about the SampleSQL.txt file
Tip: When you specify the IDCASE argument, the %INDNZ_PUBLISH_MODEL macro first determines which release of Netezza is being used.
If Netezza release 5.0 or later is being used, the macro then checks to see whether the LOWERCASE or UPPERCASE option is set for the database by using SQL statement SELECT IDENTIFIER_CASE. If the value of the IDCASE argument is different from the case configuration of the database, the macro overwrites the value of the IDCASE option and uses the case configuration of the database.
If an earlier release of Netezza is being used, the macro uses the value of the IDCASE argument.
OUTDIR=diagnostic-output-directory
specifies a directory that contains diagnostic files.
Files that are produced include an event log that contains detailed information about the success or failure of the publishing process and sample SQL code (SampleSQL.txt). For more information about the SampleSQL.txt file, see Scoring Function Names.
Tip
This argument is useful when testing your scoring models.

Model Publishing Macro Example

%indnzpm;
%let indconn = server=netezbase user=user1 password=open1 database=mydb;
%indnz_publish_model(dir=C:\SASIN\baseball1, modelname=baseball1);
This sequence of macros generates a separate .c file for each output parameter of interest. Each output stub calls into a shared scoring main which is compiled first. The %INDNZ_PUBLISH_MODEL macro also produces a text file of Netezza CREATE FUNCTION commands as shown in the following example.
Note: This example file is shown for illustrative purposes. The text file that is created by the %INDNZ_PUBLISH_MODEL macro cannot be viewed and is deleted after the macro is complete.
CREATE FUNCTION baseball1_EM_eventprobablility
(
"CR_ATBAT" float,
"CR_BB" float,
"CR_HITS" float,
"CR_HOME" float,
"CR_RBI" float,
"CR_RUNS" float,
"DIVISION" varchar(31),
"LEAGUE" varchar(31),
"NO_ASSTS" float,
"NO_ATBAT" float,
"NO_BB" float,
"NO_ERROR" float,
"NO_HITS" float,
"NO_HOME" float,
"NO_OUTS" float,
"NO_RBI" float,
"NO_RUNS" float,
"YR_MAJOR" float
)
RETURNS float
LANGUAGE CPP
PARAMETER STYLE npsgeneric
CALLED ON NULL INPUT
EXTERNAL CLASS NAME 'Cbaseball1_em_eventprobability'
EXTERNAL HOST OBJECT '/tmp/tempdir_20090506T113450_316550/baseball1.o_x86'
EXTERNAL NSPU OBJECT '/tmp/tempdir_20090506T113450_316550/baseball1.o_diab_ppc';
DEPENDENCIES dbjazlib..sas_jazlib  /* if TwinFin system */

After the scoring functions are installed, they can be invoked in Netezza using SQL, as illustrated in the following example. Each output value is created as a separate function call in the select list.
select baseball1_EM_eventprobability
( 
"CR_ATBAT",
"CR_BB",
"CR_HITS",
"CR_HOME",
"CR_RBI",
"CR_RUNS",
"DIVISION",
"LEAGUE",
"NO_ASSTS",
"NO_ATBAT",
"NO_BB",
"NO_ERROR",
"NO_HITS",
"NO_HOME",
"NO_OUTS"
) as homeRunProb from MLBNetz;