• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 43
  • Last Modified:

Explicit pass through SAS

I need help with writing an explicit pass through query in SAS eg.

I am two tables from the test schema, test.tableA and test.tableB.   TableB is a huge table and I need to pull 5 records from tableB  where they match in tableA.  I am thinking that an explicit pass through would be the best way to execute this because of the run time.  So from tableB, I need sample_A, sample_B, sample_C, sample_D, sample_E.  The sampleA column is a date field and I would need to select a particular day to shorten the run time and the result set.  From tableA, I need columnT, columnX, columnAA.  In tableB, the sampleE column is the primary key and in tableB, columnX is the key that can be used to join on.

Any help is appreciated.
0
daintysally
Asked:
daintysally
1 Solution
 
IanStatisticianCommented:
Hi there DaintySally,

My experience is that without anything special, PROC SQL will pass a query to the external database where possible, whereas PROC FEDSQL is more restricted.

My suggestions

A/ use PROC SQL with the join such that if you presented that query directly to the database you would have efficient processing.

eg
select     A.columnT, 
           A.columnX,
           A.columnAA,
           B.sample_A,
           B.sample_B,
           B.sample_C,
           B.sample_D,
           B.sample_E
from       extern.TableA as A
inner join extern.TableB as B
on         (A.columnX = B.columnX)
where      (B.sampleA = "<date in format for external database>");

Open in new window


B/ use the explicit "connection to" syntax of proc sql, whereby the code is explicitly passed through to the external database.
 
 
I would try to keep to straight PROC SQL and let sas do any necessary translation etc and query execution pass through.  Depending on the size of ColumnX in tableA you could try directly feeding the (you suggested 5) values  to join on direct to a TableB sub-query as in

select   X, Y, Z, ...
form     extern.TableB
where    columnX in ( <your 5 values in here either as values or a select clause to return 5 values>)

Open in new window

SAS will automatically use an index if available, not sure if your external database will.

-------

You should use a timer to see how the various ways of retrieving the data perform.

Regards.


.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now