There are two important
features for WHERE clause processing that are related to the IMSTAT
procedure. The first is that the WHERE clause is applied to the data
by the server. When you use a WHERE clause to subset data, the subsetting
is performed by the server. Only the rows that meet the WHERE clause
criteria are affected by subsequent operations.
The second important
feature for WHERE clause processing is related to the RUN-group processing
that the IMSTAT procedure supports. You can modify the WHERE clause
between statements. Unless a WHERE clause is specified in a RUN block,
no subsetting of rows occurs. In the following code example, the SUMMARY
statement in the first RUN-group is not subject to a WHERE clause.
The FREQUENCY statement in the second RUN-group applies only to observations
for which Division='EDUCATION.'
proc imstat data=example.prdsale(tag=sashelp);
summary actual predict / groupby=(region);
run;
where division='EDUCATION';
frequency prodtype;
run;
If you specify WHERE
clauses in different RUN blocks, the clauses replace each other. A
note is written to the SAS log to indicate the change. For example,
the SUMMARY statement in the following code example applies to observations
for which the Division='CONSUMER.' The FREQUENCY statement
applies to observations for which Region='EAST.'
proc imstat data=example.prdsale(tag=sashelp);
where division='CONSUMER';
summary actual predict / groupby=(region);
run;
where region='EAST';
frequency prodtype;
run;
When the FREQUENCY
statement runs, the following line is added to the SAS log.
NOTE: WHERE clause has been replaced.
WHERE clauses can remain
active across RUN statements. The following example is the same as
the previous example, except that the second WHERE clause is not submitted.
proc imstat data=example.prdsale(tag=sashelp);
where division='CONSUMER';
summary actual predict / groupby=(region);
run;
/* where region='EAST'; */
frequency prodtype;
run;
In this case, the SAS
log includes the following note.
NOTE: A WHERE clause remains active from a previous RUN
block: '(division='CONSUMER')'.
You can clear a WHERE
clause by submitting WHERE;
.
Each time you access
a different table with the TABLE statement, the WHERE clause is cleared.
In following example, the second FREQUENCY statement is not restricted
to observations for which Region='EAST' because the TABLE
statement that accesses Prdsal2 clears the WHERE clause.
proc imstat;
table example.prdsale(tag=sashelp);
where region='EAST';
frequency prodtype;
run;
table example.prdsal2(tag=sashelp);
frequency prodtype;
run;
The SAS log indicates
that the WHERE clause is no longer applied.
NOTE: The WHERE statement is cleared when you open a LASR Analytic Server
table with the TABLE statement.