全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3893 6
2013-10-28
SAS里有两表要合并,表一中有字段a,b;表二中有字段c;两表合并的条件是c的值在a和b之间。我只知道sql的between and语句可以实现,但运行速度很慢,不知道hash能否实现相同功能呢?求指点。。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-10-28 12:10:21
depends on you data
if those [a,b] intervals are mutually exclusive, there're ways to fine-tune the join.
on the other hand, if there are many overlaps, it's beyond me.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-28 13:02:19
Try if this code
The results may be slightly different from that of sql, due to the replicate.
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-28 14:42:08
yongyitian 发表于 2013-10-28 13:02
Try if this code
The results may be slightly different from that of sql, due to the replicate.
谢谢。确实达到了目的,还有一个问题:hash里使用不等式条件是不是比使用等式条件慢?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-28 20:50:45
"If neither contributing dataset is sorted, but one of them does fit into memory, PROC SQL will choose to process the query with a Hash Join (sqxjhsh)" (http://support.sas.com/techsup/technote/ts553.html)
Make sure you have enough memory, and the SQL join will be as efficient as Yongyitian's program.
The option is buffersize (http://support.sas.com/resources ... ings10/139-2010.pdf)
In either method, a Cartisian product is involved, so they should be spending very similar amount of time. It's not a problem as long as you can get your results in a reasonable amount of time.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-10-28 20:51:08
"If neither contributing dataset is sorted, but one of them does fit into memory, PROC SQL will choose to process the query with a Hash Join (sqxjhsh)" (http://support.sas.com/techsup/technote/ts553.html)
Make sure you have enough memory, and the SQL join will be as efficient as Yongyitian's program.
The option is buffersize (http://support.sas.com/resources ... ings10/139-2010.pdf)
In either method, a Cartisian product is involved, so they should be spending very similar amount of time. It's not a problem as long as you can get your results in a reasonable amount of time.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群