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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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