proc sql;
create table inner_one As
select g.stu_id, score1, score3
from score_data_g as g inner join
score_data_ng as ng
on g.stu_id=ng.stu_id;
/* on score_data_g.stu_id = score_data_ng.stu_id; */
quit;
proc sql;
create table inner_one As
select g.stu_id, score1, score3
from score_data_g as g,
score_data_ng as ng
/* where g.stu_id=ng.stu_id; */
/* where score_data_g.stu_id = score_data_ng.stu_id; */
where g.stu_id = ng.stu_id;
quit;
In two codes above, the on clause in inner join can be replaced by the where clause. But it does not work for outer join
(left, right and full join). In both the where clause and the inner join, it seems that order of two datasets does
not make different.
Does this correct?
Using a WHERE in SQL is equivalent to an inner join.
Using a WHERE in SQL is equivalent to an inner join.
For an inner join of two data sets "on" clause is used and two data sets are listed with "inner join" but for 'where' two data sets are separated by a comma.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.