【发布时间】:2016-12-30 15:11:05
【问题描述】:
我正在尝试在 SQL 直通中合并 SAS 表,以帮助减少查询 SQL 数据库所需的时间。目前我只是按原样使用直通,大约需要 8-9 个小时才能从表中提取所有内容,然后再选择我想要的内容。
目前的直通看起来是这样的:
proc sql;
connect to ODBC as CAW(datasrc = "CAW_ULI_STATIC");
create table test as
select aelref, aelprdtyp, aelsubtyp, aelloc, aelopndte,
hdscontrolopendate, hdscontrolclosedate, hdscontrolaction,
from connection to CAW (
select aelref, aelprdtyp, aelsubtyp, aelloc, aelextnbr, aelbrnpfx, aelitnnbr, aelopndte,
aelclddte, hdscontrolopendate, hdscontrolclosedate, hdscontrolaction
from PUBLIC_withpersonal_short.Vwhdscisagrmnt (nolock)
where HDSControlACTION <> 'D'
and aelsubtyp in (1, 2, 3, 4, 5, 10, 20, 21)
order by aelref, hdscontrolopendate, hdscontrolclosedate
);
disconnect from CAW;
;
quit;
但我现在正尝试使用另一个 SAS 数据集通过左连接来缩小我从直通中提取的范围,因此它看起来像这样:
proc sql;
connect to ODBC as CAW(datasrc = "CAW_ULI_STATIC");
create table test as
select a.*, aelref, aelprdtyp, aelsubtyp, aelloc, aelopndte,
hdscontrolopendate, hdscontrolclosedate, hdscontrolaction,
from Import1 a left join connection to CAW (
select aelref, aelprdtyp, aelsubtyp, aelloc, aelextnbr, aelbrnpfx, aelitnnbr, aelopndte,
aelclddte, hdscontrolopendate, hdscontrolclosedate, hdscontrolaction
from PUBLIC_withpersonal_short.Vwhdscisagrmnt (nolock)
where HDSControlACTION <> 'D'
and aelsubtyp in (1, 2, 3, 4, 5, 10, 20, 21)
order by aelref, hdscontrolopendate, hdscontrolclosedate
);
disconnect from CAW b;
on a.ANUM = b.aelextnbr
;
quit;
但它似乎不喜欢在连接之前添加连接。这是正确的方法吗,还是我错过了什么?
谢谢。
【问题讨论】:
-
除非您的 SAS 系统真的很慢,否则几乎所有的 8-9 小时都花在了远程处理和发回数据上。事后过滤不会对性能有太大帮助。
-
什么 RDMS? SQL Server、Oracle、DB2、Postgres、MySQL?在 DBMS 控制台中查询需要多长时间? SAS 是与数据库驻留在同一服务器上还是远程驻留?
标签: sql sas left-join pass-through