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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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