1

我正在尝试自动化一项工作,该工作涉及通过网络以及在实际 db2 服务器和我们的 SAS 服务器之间传递的大量数据。我想做的是通过传统的通行证...

proc sql;
 connect to db2(...);
 create table temp as 
 select * from connection to db2(
    select
     date 
    .......
    where 
     date between &start. and &stop.
); disconnect from db2;
quit;

变成这样的东西:

x "db2 'insert into temp select date ...... where date between &start. and &stop.'";

我遇到了一些问题,其中第一个是'ddMONyyyy'd 的db2 日期格式,它会导致shell 命令提前终止。如果我能解决这个问题,我认为它应该可以工作。

我可以将宏变量传递给 AIX (SAS) 服务器,而无需执行 db2 命令所需的额外“ ”集。

有什么想法吗?

4

1 回答 1

2

您可以通过在 WHERE 子句中加上括号来绕过日期问题的单引号。我不确定这是否可行,但可能值得一试。

至于 X 命令,请尝试以下操作:

%let start = '01jan2011'd;
%let stop  = '31dec2011'd;

%let command_text = db2 %nrbquote(')insert into temp select date ... where (date between &start. and &stop.)%nrbquote(');
%put command_text = &command_text;
x "&command_text";
于 2011-09-02T19:54:23.777 回答