SAS-> Shell DB2 直通和宏解析

发布于 2024-12-02 20:07:15 字数 610 浏览 0 评论 0原文

我正在尝试自动化一项工作,该工作涉及通过网络以及实际 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 命令所需的额外“ ”集。

有什么想法吗?

I'm trying to automate a job that involves a lot of data being passed across the network and between the actual db2 server and our SAS server. What I'd like to do is take a traditional pass through...

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;

into something like this:

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

I'm running into a few issues the first of which is db2 date format of 'ddMONyyyy'd which causes the shell command to terminate early. If I can get around that I think it should work.

I can pass a macro variable through to the AIX (SAS) server without the extra set of ' ' needed to execute the db2 command.

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肥爪爪 2024-12-09 20:07:15

您可以通过用括号隔开 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";

You might get around the single-quote around the date issue by setting off the WHERE clause with a parenthesis. I'm not sure that this will work, but it might be worth trying.

As far as X command, try something like the following:

%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";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文