DATA Step Programming for Scoring In SAS LASR Analytic Server

Scoring In-Memory Tables Using DATA Step Processing

The DATA step can process in-memory tables for scoring with limitations:
  • Only one input file and one output file is allowed.
  • Only functions and formats that are supported by the DS2 language compile successfully.
  • Some DATA step statements are not allowed, such as those pertaining to input and output.
To enable the DATA step to score in-memory SAS tables, set the system option DSACCEL=ANY.
If a SAS program does not meet the requirements for running in the SAS LASR Analytic Server, SAS writes informational or error messages to the log and executes the code in your Base SAS session. In this case, SAS reads and writes large tables over the network.
You can determine whether your code is compliant with the SAS LASR Analytic Server compiler by setting the system option MSGLEVEL= to I. When MSGLEVEL=I, SAS writes log messages that identify the non-compliant code.

Example 1: A DATA Step Program For SAS LASR Analytic Server

This example demonstrates executing a DATA step program in the SAS LASR Analytic Server:
/* Enable DATA step parallel processing using the system option   */
/* and enable messages to view non-compliant code in the SAS log. */
options dsaccel=any msglevel=i;

/* Create a libref for in-memory tables. */
libname lasr sasiola host="grid001.example.com" port=10010 tag='hps';

/* Create a libref for the input data that is stored on disk. */
libname score '/myScoreData/';

/* Load the input table into memory */
data lasr.intr;
   set score.intrid;
run;

/* Execute the score code using the in-memory tables. */
/* Both tables must use the same libref.              */
data lasr.sumnormtable;
   set lasr.intr;

/* Execute the score code. */
if sum > 1000
  then score=1;

run;

Example 2: Using User-Defined Formats with In-Memory Tables

You can use user-defined formats in a DATA step by using the CATALOG procedure to copy the format catalog to a library. This example copies the format library to Work:
/* Enable DATA step parallel processing using the system option   */
/* and enable messages to view non-compliant code in the SAS log. */

options dsaccel=any msglevel=i;

/* Create a libref for the in-memory tables. */
libname lasr sasiola host="grid001.example.com" port=10010 tag='hps';

/* Create a libref for the input data and format catalog that is  */
/* stored on disk.                                                */
libname score '/myScoreData/';

/* Copy the demx format catalog to the Work library */
proc catalog catalog=score.dmex; 
   copy out=work.formats; 
quit;

/* Enable in-memory processing (dsaccel) and load the input table */
/* into memory.                                                   */
data lasr.dmex;
   set score.dmex;
run;

/*  Enable in-memory processing (dsaccel) and execute the score code .*/
/*  using the in-memory tables.                                       */
data lasr.dmexout;
   set lasr.dmex;
   %inc "dmex.sas";
run;

SAS automatically searches the Work and Library libraries for a format catalog. If you copy the format library to a library other than Work or Library, then you must use the FMTSEARCH= system option to let SAS know the location of the format library.
options fmtsearch=(myFmtLib);
You must also specify the FMTSEARCH= system option if the format catalog name is not format:
options fmtsearch=(myFmtLib.myFmts);

Requirements for LASR Score Mode DATA Step Processing

In order to score in-memory tables in SAS LASR Analytic Server, the following is required:
  • The DSACCEL=ANY system option is set.
  • The code must contain a LIBNAME statement using the SASIOLA engine.
  • The input and output tables must use the same libref for the SASIOLA engine.
  • The DATA statement must be followed immediately by the SET statement.
    This example demonstrates these requirements:
    libname lasr sasiola;
    data lasr.out;
       set lasr.in;
       /* DATA step code */
    run;

Restrictions in DATA Step Processing

Here are the restrictions for using the DATA step in SAS LASR Analytic Server:
  • More than one SET statement is not supported. SET statement options are not allowed.
  • The statements in the following table are not supported as part of a DATA step. The Alternative column provides possible alternatives, if one is available.
    DATA Step Statement
    Alternative
    BY (or FIRST. and LAST. variables)
    CARDS and CARDS4
    CONTINUE
    DISPLAY
    ERROR
    FILE
    Subsetting IF
    Two options are available. You can write a program that includes a subsetting IF and use the SCORE statement. Another option is use to use the BALANCE statement. See the example.
    INFILE
    INPUT
    LEAVE
    LIST
    LOSTCARD
    MERGE
    You might be able to use the SCHEMA Statement to produce similar results.
    MISSING
    MODIFY
    OUTPUT
    You can use the __lasr_output variable in a program with the SCORE statement to control when to output an observation. You can write observations to a single output table only.
    PUT
    A PUT statement in a program that is used with the SCORE statement writes entries to a temporary table instead of to the SAS log. You can view the results of the PUT statements by specifying the PGMMSG option in the IMSTAT statement and then viewing the contents of the &_PGMMSG_ temporary table. For an example, see Using the RETAIN Statement.
    REMOVE
    RENAME
    REPLACE
    RETAIN
    You can specify the DSRETAIN option to the SCORE statement and use the RETAIN statement in your program. See Using the RETAIN Statement.
    UPDATE
    You can use the DATA= option with the UPDATE statement to make changes to a table. However, this statement updates the active table rather than creating a new table. See Update with a Data Set.
    WHERE
    The statements in the IMSTAT procedure that operate on observations are subject to a WHERE statement. To create a new in-memory table from a subset of rows in the active table, you can specify a WHERE clause and then use the BALANCE statement.
    WINDOW
  • The ABORT statement has these restrictions:
    • The ABORT statement does not accept arguments.
    • The ABORT statement is not supported within functions. It is valid only in the main program.
  • The DO statement does not accept a character index. For example, the following statement results in an error: do month='JAN','FEB','MAR';.
  • These functions are not supported:
    • DIF
    • LAG
  • The INPUT function does not support the question mark (?) and double question mark (??) modifiers.
  • Some CALL routines are not supported. Routines are supported if there is an equivalent function.
  • You can use only SAS formats and functions that are supported by the DS2 language. These formats and functions are documented in SAS DS2 Language Reference.
  • Component objects are not supported.
  • Scoring input variables cannot be modified.