BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
What is difference between
Libname statement and sql pass thru query
3 REPLIES 3
Ksharp
Super User
Libname statement need translate sas sql into local sql,
while pass thru don't , just pass local sql into DB and run sql at DB side ,so it is faster then libname .
SASKiwi
PROC Star

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.

 

 

ChrisNZ
Tourmaline | Level 20

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;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1110 views
  • 3 likes
  • 4 in conversation