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
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.
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.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.