这篇文章给大家分享的是有关表链接proc sql的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。 proc sql; select *&nb
这篇文章给大家分享的是有关表链接proc sql的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
proc sql;
select * from resdat.china, resdat.usa;
quit
proc sql;
select * from resdat.china, resdat.usa
where china.level=usa.level;
quit;
proc sql;
select * from resdat.china as a, resdat.usa as b
where a.level=b.level;
quit;
proc sql;
select * from resdat.china a, resdat.china b
where a.level<b.level;
quit;
proc sql;
select * from resdat.china a, resdat.china b
where a.level<b.level
order by a.level desc;
quit;
proc sql;
title ' Table A and B Joined';
select a.obs 'A-OBS', a.stkcd, b.obs 'B-OBS', b.stkcd
from a, b
where a.stkcd= b.stkcd;
proc sql;
title ' Table Three and Four Joined';
select Three.Obs '3-OBS', Three.Fdcd, Four.Obs '4-OBS', Four.Fdcd
from Three, Four
where Three.fdcd= Four.fdcd and
three.fdcd is not missing;
proc sql outobs=3;
select a.stkcd,b.lstknm,c.clpr
from resdat.sampstk a,resdat.lstkinfo b,resdat.Qttndist c
where a.stkcd=b.stkcd and b.stkcd=c.stkcd and a.stkcd=c.stkcd;
quit;
proc sql;
select * from resdat.china a left join resdat.usa b
on a.level=b.level;
quit;
proc sql;
select * from resdat.china a right join resdat.usa b
on a.level=b.level;
quit;
proc sql;
select * from resdat.china a full join resdat.usa b
on a.level=b.level;
quit;
proc sql;
select * from resdat.china cross join resdat.usa;
quit;
proc sql;
select * from resdat.china uNIOn join resdat.usa;
quit;
proc sql;
select * from resdat.china union join resdat.usa;
quit;
Proc sql;
select a.level,a.china,coalesce(b.level,a.level),coalesce(b.usa,a.china)as usa
from resdat.china a full join resdat.usa b
on a.level=b.level;
quit;
data merge1;
merge a b;
by code;
run;
proc print data=merge1 noobs;
title 'Table MERGE1';
run;
proc sql;
title 'Table MERGE1';
select a.code, a.manager, b.Assitant
from a, b
where a.code=b.code;
quit;
data merge2;
merge a b;
by code;
run;
proc print data=merge2 noobs;
title 'Table MERGE2';
run;
proc sql;
select code,a.manager,b.assistant
from a natural full join b;
quit;
data merge3;
merge a b;
by code;
run;
proc print data=merge3 noobs;
title 'Table MERGE3';
run;
Proc sql;
Title 'Table Merge3';
Select a.code, a.manager, b.assistant
From a full join b
On a.code=b.code;
quit;
Proc sql;
Title 'Which Manager has the same code as Assistant Chen';
Select *
From a
Where code eq (select code from b where assistant='Chen');
Quit;
Proc sql;
select stkcd,lstknm,lstdt from resdat.lstkinfo
where stkcd in (select stkcd from resdat.sampstk);
quit;
proc sql;
select stkcd,yrret from resdat.yrret a
where (select stktype from resdat.lstkinfo b
where a.stkcd=b.stkcd)='A'
and '1jan2005'd<=date<='31dec2005'd;
quit;
Proc sql;
select stkcd,yrret from resdat.yrret a
where stkcd in (select stkcd from resdat.sampstk b
where stkcd in(select stkcd from resdat.lstkinfo c
where c.stktype='A'))
and '1jan2005'd<=date<='31dec2005'd;
quit;
proc sql;
select a.id,b.id,sqrt((a.x-b.x)**2+(a.y-b.y)**2)as dist from point a,point b
where a.id lt b.id and
calculated dist=(select min(sqrt((c.x-d.x)**2+(c.y-d.y)**2))
from point c,point d
where c.id lt d.id);
quit;
proc sql;
title 'A UNION B';
select * from A
union
select * from B;
quit;
proc sql;
title 'A UNION ALL B';
select * from A
union all
select * from B;
quit;
proc sql;
title 'A EXCEPT B';
select * from A
except
select * from B;
quit;
proc sql;
title 'A EXCEPT ALL B';
select * from A
except all
select * from B;
proc sql;
title 'A INTERSECT B';
select * from A
intersect
select * from B;
proc sql;
title 'A OUTER UNION B';
select * from A
outer union
select * from B;
proc sql;
title 'A OUTER UNION CORR B';
select * from A
outer union corr
select * from B;
proc sql;
title 'A EXCLUSIVE UNION B';
(select * from A
except
select * from B)
union
(select * from B
except
select * from A);
感谢各位的阅读!关于“表链接proc sql的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
--结束END--
本文标题: 表链接proc sql的示例分析
本文链接: https://www.lsjlt.com/news/71586.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0