Be Aware of Implicit Pass-Through

From sasCommunity

Jump to: navigation, search

PROC SQL can automatically ask a non-SAS database to perform a join for it. While this can speed up query execution, it can also produce results which differ from those which PROC SQL alone would produce.

Here's a little example using Excel, of all things, as the supporting database. First we set up an Excel libref

libname passthru excel 'xldemo.xls';

then a second libref, this time with the DIRECT_SQL=NO option, which prohibits implicit pass-through.

libname nopass excel 'xldemo.xls' direct_sql=no;

Next, we set up two little tables in the form of Excel worksheets:

proc datasets library=xldemo kill nolist; quit; 
data xldemo.a xldemo.b; do var = 1, (.), 3; output; end; run;

Now we ask SQL to join the two tables. First, we use the libref which prevents implicit pass-through:

proc sql;
title 'NO implicit pass-through join';
select *
 from nopass.a join nopass.b
  on a.var = b.var;

The result is

var       var
-------------
  .         .
  1         1
  3         3

Now we do the same join, but with the libref which, by default, permits implicit pass-through

title 'NO implicit pass-through join';
select *
 from nopass.a join nopass.b
  on a.var = b.var;
quit;

The result is

a.var     b.var
---------------
    1         1
    3         3

The row with the two nulls (missing values) does not appear. That's because Microsoft join rules rather than SAS join rules are in effect. Microsoft's SQL implementation of SQL, like most but unlike the SAS implementation, does not consider two nulls to be equal.

There are warnings:

WARNING: The SCAN_TEXT option is ignored in the implicit pass-through joins.
WARNING: Use libname option DIRECT_SQL=NO to disable the implicit pass-through joins if you
         want the SCAN options on.

but they focus on the SCAN options whereas the implications of permitting implicit pass-through joins are broader.

Question: What warnings are issued when other data bases (not MS Office) are used?

Personal tools