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

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

我有一个包含id列的sas表,我正在查询teradata sql,条件是sql表与sas表具有相同的id。我使用以下代码:

  1. libname ss"dir";
  2. proc sql;
  3. connect to teradata(server);
  4. crreate table ss.new as select * from connection to teradata(
  5. select some from new_db where id in (select id from ss.table));

代码无法识别ss库。如何将列作为sql参数传递?

f45qwnt8

f45qwnt81#

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

  1. %let ID_LIST = 0; * just in case;
  2. proc sql noprint;
  3. * build the ID_LIST using INTO :<macro-var> syntax;
  4. select id into :ID_LIST separated by ',' from ss.table;
  5. connect to teradata(server);
  6. create table ss.new as
  7. select * from connection to teradata
  8. (
  9. select id, column1, column2, ...
  10. from new_db
  11. where id in (
  12. &ID_LIST /* code-gen, SAS will resolve the ID_LIST before passing to Teradata */
  13. )
  14. );
展开查看全部

相关问题