BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
palvani
Fluorite | Level 6

While querying the data using Proc SQL from two tables without using aliases, the program seems to run fine without using libref in On clause. How does SAS recognize if the table we are referring to is from work or a particular library(pg1 in the below example)?

Ex:

proc sql;
select Season, Name, storm_summary.Basin, BasinName, MaxWindMPH
from pg1.storm_summary inner join pg1.storm_basincodes
on storm_summary.Basin = storm_basincodes.Basin
order by Season desc, Name;
quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Al14
SAS Employee
The ON clause can only access tables from the FROM clause. In your example, pg1.storm_summary and pg1.storm_basinCodes are the only tables the ON clause considers

View solution in original post

3 REPLIES 3
Al14
SAS Employee
The ON clause can only access tables from the FROM clause. In your example, pg1.storm_summary and pg1.storm_basinCodes are the only tables the ON clause considers
Tom
Super User Tom
Super User

In an ON clause you are referencing VARIABLES, not DATASETS.

 

So depending where you use X.Y it means different things.

 

In SQL code referencing a variable the X value (called an ALIAS) specifies the dataset and the Y value specifies the variable in that dataset.

 

In SAS code referencing a dataset the X value (called a LIBREF) specifies the library and the Y value specifies the dataset (called a MEMBER) in that library.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

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