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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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