IMSTAT Procedure (Data and Server Management)

UPDATE Statement

The UPDATE statement performs rowwise updates of the data in an in-memory table.

Syntax

UPDATE variable1=value1 <variable2=value2 ...> </ options>;
UPDATE DATA=libref.member-name </ options>;

Required Arguments

variable

specifies the name of the variable to update.

Note: Because DATA= is a keyword, you cannot specify it as a variable name. For an example of how to modify a variable named Data, see Update with a Data Set.

value

specifies the value to assign to the variable.

DATA=libref.member-name

specifies the libref and table name of a SAS data set to use for updating the in-memory table. The data set must contain the variables and values that you want to update. You can specify a _WHERE_ variable in the data set to apply as a filter to the particular set of update values. This clause in the data set augments the overall WHERE clause, if one is specified.

UPDATE Statement Options

CODE=file-reference

specifies a file reference to a SAS program to use for the row update (an update script). You can combine the specification of a SAS program through the CODE= option with the name-value pair specification or the DATA= specification for bulk updates. The updates that are specified in the name-value pair and DATE= specifications are performed first and then the update script executes on the modified row to produce the update.

Alias PGM=

NOPREPARSE

prevents the procedure from pre-parsing and pre-generating code for temporary expressions, scoring programs, and other user-written SAS statements.

When this option is specified, the user-written statements are sent to the server "as-is" and then the server attempts to generate code from it. If the server detects problems with the code, the error messages might not to be as detailed as the messages that are generated by SAS client. If you are debugging your user-written program, then you might want to pre-parse and pre-generate code in the procedure. However, if your SAS statements compile and run as you want them to, then you can specify this option to avoid the work of parsing and generating code on the SAS client.
When you specify this option in the PROC IMSTAT statement, the option applies to all statements that can generate code. You can also exclude specific statements from pre-parsing by using the NOPREPARSE option in statements that allow temporary columns or the SCORE statement.
Alias NOPREP

SAVE=table-name

saves the result table so that you can use it in other IMSTAT procedure statements like STORE, REPLAY, and FREE. The value for table-name must be unique within the scope of the procedure execution. The name of a table that has been freed with the FREE statement can be used again in subsequent SAVE= options.

TEMPEXPRESS="SAS-expressions"

TEMPEXPRESS=file-reference

specifies either a quoted string that contains the SAS expression that defines the temporary variables or a file reference to an external file with the SAS statements.

Alias TE=

TEMPNAMES=variable-name

TEMPNAMES=(variable-list)

specifies the list of temporary variables for the request. Each temporary variable must be defined through SAS statements that you supply with the TEMPEXPRESS= option.

Alias TN=

Details

Usage Notes

It is common to use the UPDATE statement with a WHERE clause. The clause filters the rows to which the updates are applied. If you are unsure about the number of rows that can be updated, use the NUMROWS statement to determine how many rows would be affected by the rowwise update.
Note: The ODS output of the UPDATE statement indicates the number of rows that were updated. This value actually indicates the number of rows that met the condition in the WHERE clause, not the number of rows that were modified.
You can update the values of ORDERBY variables, but you cannot update the value of variables that are used for constructing partition keys.
You cannot update the values of permanent computed variables. Their values are determined by the SAS program that originally defined them.

ODS Table Names

The UPDATE statement generates the following ODS table.
ODS Table Name
Description
Option
RowUpdate
Number of Rows Considered for an Update
Default
For information about using the ODS table with SAVE= option, see the Details section of the STORE statement.

Examples

Example 1: Update with a SAS Program

libname example sasiola host="grid001.example.com" port=10010 tag=hps;

data example.prdsale;
    set sashelp.prdsale;
run;

filename pgm "some-path/update.pgm";  1
data _null_;
    file pgm;
    put "if quarter=3 and product eq 'SOFA' then do;";
    put "  predict = 1.05 * predict;";
    put "end;";
    put "if quarter=3 and product ne 'SOFA' then do;";
    put "  predict = 1.03 * predict;";
    put "end;";
run;

proc imstat data=example.prdsale;  2
    /* columninfo; */
    /* fetch / format; */

    update / code=pgm;
run;

    where quarter=3;
    fetch / format;
quit;
1 The FILENAME statement and the DATA statement are used to write a simple SAS program to a file. The file reference, Pgm, is used later in the UPDATE statement.
2 In the PROC IMSTAT example, the COLUMNINFO and FETCH statements are enclosed in comments, but they are helpful for helping you understand the data. The UPDATE statement uses the CODE= option to specify the file reference. The WHERE statement and FETCH statements are used to display the first 20 rows that were updated.

Example 2: Update with a Data Set

libname example sasiola host="grid001.example.com" port=10010 tag=hps;

data example.tableA;  1
  do x=11 to 20;
    data = x;
    output;
  end;
run;

data pgm;  2
  length _where_ $64;
  _where_ = "x between 5 and 13";
  data = 10;
output;
  _where_ = "x between 14 and 30";
  data = 15;
output;
run;

proc imstat data=example.tableA;
  fetch / format; run;
quit;

proc imstat data=lasr.tableA;
  update data=pgm;  3
run;
  fetch / format orderby=(x);
quit;
1 The SAS LASR Analytic Server engine and a DATA step are used to create a simple in-memory table with columns named x and Data.
2 A data set, named Pgm, is created in the Work library. The data set describes two updates to make an in-memory table. The _WHERE_ column is used to specify the rows to modify.
3 The DATA= option is used to specify the data set with the update instructions.
The following display shows the original in-memory table before it is modified by the UPDATE statement.
The original in-memory table.
The following display shows the number of rows that were considered for an update (the number of rows that met the _WHERE_ criteria) and the result of the UPDATE statement.
Number of rows considered for an update and the results of the update.