【sas sql proc】inner join or outer join
1 proc sql; 2 title 'table 1+11'; 3 select * from mysas.ifthen1,mysas.ifthen11; 4 quit; 5 6 proc sql; 7 title 'table 1'; 8 select * from mysas.ifthen1; 9 10 title 'table11'; 11 select * from mysas.ifthen11; 12 quit;
第一段显示的是两表联合的笛卡尔积结果。
第二段仅是分别显示两表。
1 proc sql; 2 title 'table1 inner jion table11'; 3 select a.gtone as g from mysas.ifthen1 a,mysas.ifthen11 b 4 where a.gtone=b.gtone; 5 quit; 6 proc sql; 7 title 'table1 inner jion table11'; 8 select a.gtone 'g' from mysas.ifthen1 a,mysas.ifthen11 b 9 where a.gtone=b.gtone; 10 quit;
行的别名,两种方式一种是标签,另一种是另起名。
from where 和inner join +on的作用一致 inner join +on是为了和left/right join on 相统一。
1 proc sql; 2 title 'self join'; 3 select a.gtone,b.shen 4 from mysas.ifthen1 a,mysas.ifthen1 b 5 where a.date=b.date; 6 quit;
用别名可以实现自身与自身的查询。