BookmarkSubscribeRSS Feed
MadhuKorni
Quartz | Level 8

Hi,

 

If we want to pull the data from a database to SAS, which approach is more efficient? Libname or Proc SQL Connect to?

 

Regards,

Madhu

3 REPLIES 3
andreas_lds
Jade | Level 19

The libname statement does not pull anything, it establishes a connection to the database, so that the tables can be used as if they are datasets. Efficiency depends on the size of the tables and what you want to do with the data.

LinusH
Tourmaline | Level 20

If you use "simple" filtering, they should be equally efficient.

But if you are doing advances logic in the query, explicit pass through (FROM CONNECTION TO) might be faster.

 

My preference is to use LIBNAME connections if possible, since it is simpler to code, and potentially RDBMS independent.

Data never sleeps
Tom
Super User Tom
Super User

The advantage of using a LIBREF is that SAS will convert your queries into appropriate code for the remote database.

The advantage of using SQL is that you can write your own query in pass-thru code and potentially do a better job of making that SQL efficient.

 

Of course you could just use your libref in your SQL code.

libname mylib oracle .... ;
proc sql ;
  connect using mylib;
  ....
quit;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2915 views
  • 3 likes
  • 4 in conversation