如何在 teradata sql 中传递列表变量?
how to pass list variable in teradata sql in sas?
我有 sas table 包含 id 列,我正在查询 teradata sql 条件 sql table 与 sas table 具有相同的 id ].我使用下面的代码:
libname ss"dir";
proc sql;
connect to teradata(server);
crreate table ss.new as select * from connection to teradata(
select some from new_db where id in (select id from ss.table));
代码无法识别 ss 库。我如何将列作为 sql 参数传递?
如果 ID
值列表的长度小于 64K 个字符,您可以使用宏为显式 IN
列表生成源代码 (code-gen) 片段。
%let ID_LIST = 0; * just in case;
proc sql noprint;
* build the ID_LIST using INTO :<macro-var> syntax;
select id into :ID_LIST separated by ',' from ss.table;
connect to teradata(server);
create table ss.new as
select * from connection to teradata
(
select id, column1, column2, ...
from new_db
where id in (
&ID_LIST /* code-gen, SAS will resolve the ID_LIST before passing to Teradata */
)
);
我有 sas table 包含 id 列,我正在查询 teradata sql 条件 sql table 与 sas table 具有相同的 id ].我使用下面的代码:
libname ss"dir";
proc sql;
connect to teradata(server);
crreate table ss.new as select * from connection to teradata(
select some from new_db where id in (select id from ss.table));
代码无法识别 ss 库。我如何将列作为 sql 参数传递?
如果 ID
值列表的长度小于 64K 个字符,您可以使用宏为显式 IN
列表生成源代码 (code-gen) 片段。
%let ID_LIST = 0; * just in case;
proc sql noprint;
* build the ID_LIST using INTO :<macro-var> syntax;
select id into :ID_LIST separated by ',' from ss.table;
connect to teradata(server);
create table ss.new as
select * from connection to teradata
(
select id, column1, column2, ...
from new_db
where id in (
&ID_LIST /* code-gen, SAS will resolve the ID_LIST before passing to Teradata */
)
);