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.
daintysallyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Statistical Analysis System (SAS)

From novice to tech pro — start learning today.