如何在sas中传递teradatasql中的list变量?

mcvgt66p  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(349)

我有一个包含id列的sas表,我正在查询teradata sql,条件是sql表与sas表具有相同的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参数传递?

f45qwnt8

f45qwnt81#

如果 ID 值的长度小于64k个字符您可以使用宏为显式 IN 列表。

%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 */ 
    )
  );

相关问题