This document discusses using SQL pass-through queries in SAS to more efficiently extract and transform data from relational database management systems (RDBMS) like Oracle, DB2, and SQL Server. It describes how pass-through queries process data directly in the RDBMS using native SQL functions rather than bringing entire tables into SAS, improving speed for complex queries. It also addresses differences between RDBMS like naming conventions and numeric precision that can cause issues if not handled properly in pass-through queries.
10. Processing Location Affects Processing Speed "No one will believe you solved this problem in one day! We've been working on it for months. Now, go act busy for a few weeks and I'll let you know when it's time to tell them." --submission from a real-life “Dilbert Quotes” contest
11. Processing Location... Regular Query does processing work in SAS on your PC using SAS functions Pass-Through Query does processing work in RDBMS where the data is stored using “native” Oracle/DB2 functions Faster!!
15. Original Query proc sql; create table work.s1_claim_row as select put(claim_uid,best16.) as claim_uid length= 16 from prodj.s1_claim ; quit;
16.
17. Solution (SAS/Access Interface to ODBC) proc sql; connect to odbc(datasrc = "PRODJ" user=xxxxxxxxxxx password=xxxxxxxxxxxx); create table work.s1_claim_row as select * from connection to odbc (select to_char(claim_uid,'0000000000000000') as claim_uid from onesource_o.s1_claim ) ; disconnect from odbc; quit;
18. Solution (SAS/Access Interface to Oracle) proc sql; connect to oracle(path = "prodj.cigna.com" user=xxxxxxx password=xxxxxxx); create table work.s1_claim_row as select * from connection to oracle (select to_char(claim_uid,'0000000000000000') as claim_uid from onesource_o.s1_claim ) ; disconnect from oracle; quit;
"I saw the code for your computer program yesterday. It looked easy. Its just a bunch of typing. And half of the words were spelt wrong. And don’t get me started on your over-use of colons." - The Pointy-Haired Boss
Add example logs with times contrasting pass-through query time w non-pass-through? Especially faster for complex joins (i.e. mutiple fields) on large tables b/c rdbms is typically optimized to handle such queries. Non pass through: entire tables brought into SAS, SAS does query, produces results Pass through: avoids large data movement, query is done in the database which is optimized to handle the queries, and only results are returned to SAS The more tables being referenced and the larger the tables, the greater the difference in speed.
Add example logs with times contrasting pass-through query time w non-pass-through? Especially faster for complex joins (i.e. mutiple fields) on large tables b/c rdbms is typically optimized to handle such queries. Non pass through: entire tables brought into SAS, SAS does query, produces results Pass through: avoids large data movement, query is done in the database which is optimized to handle the queries, and only results are returned to SAS The more tables being referenced and the larger the tables, the greater the difference in speed.
Or Using Libname clause: proc sql; create table work.s1_claim_row as select * from prodj.s1_claim using libname prodj oracle user=xxxxxxxx password=xxxxxxx path=‘prodj.cigna.com'; quit; Another example of explicit pass-through. Also try using proc sql options _method and _tree to show order of joins and which parts of the query were processed through/passed to the rdbms. Good when trying to join several tables in a database with a sas dataset.
Add non-odbc pass-through syntax for db2?
Or maybe you’re more fluent in another dialect of SQL