A LIBNAME statement connecting to an external database versus an SQL Passthru doing the same - both have advantages and disadvantages:
LIBNAMEs are easier and can be automated for all SAS sessions via SAS metadata or SAS AUTOEXECs but can't handle table names greater than 32 characters long. They can be directly used in DATA steps and many SAS procedures.
SQL Passthru is more powerful, more customisable, and is the only way to access table names greater than 32 characters long, but you need to know the SQL syntax of the database you are querying and can only be used in PROC SQL.
This is a badly worded question.
Libnames enable a connection. SQL (passthru or not) can use the connection to access data.
So they are not mutually exclusive. They don't do the same thing.
This means that they be used together:
libname ORADATA oracle user= ....;
proc sql;
connect using ORADATA;
select * from ( /* Use SAS SQL before the ( */
select * from ... /* Use Oracle SQL between ( and ) */
) ; /* Use SAS SQL after the ( */
quit;
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!
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.
Ready to level-up your skills? Choose your own adventure.