1

I'm attempting to use SASDOS in my statement below, but it's failing to be found. My understanding is that I have to use a form of derived table to access this new column. Is this correct? If so, could someone please help elaborate on how to do that?

proc sql;
   create table TEST as 
   select 
      DQBBDA AS 'Sbm Date'n,
      case when 'Sbm Date'n > 999999
         then input('1' || substr(put('Sbm Date'n,z8.),3), z7.)
      end as SASDOS format=z7.
   from 
      DB2SCHEMA.ORIGIN
   where 
      SASDOS = 1130314;
quit;
4

2 回答 2

4

正如 sasfrog 评论的那样,您需要添加 CALCULATED 关键字来引用 SAS SQL 中的新列,并且您应该在查询中引用本机 DB2 列。例如:

proc sql;
    create table TEST as 
    select DQBBDA AS 'Sbm Date'n
         , case when DQBBDA > 999999
                then input('1' || substr(put(DQBBDA,z8.),3), z7.)
            end as SASDOS format=z7.
    from DB2SCHEMA.ORIGIN
    WHERE CALCULATED SASDOS = 1130314;
quit;

但是,您真的应该重新考虑您在做什么,并弄清楚如何编写一个使用DB2 中的列的WHERE子句;否则必须将整个表拉回 SAS(可能是一个糟糕的解决方案)。使用pass-thru查询(您可以在 DB2 中直接执行本机 SQL)可能会更好地解决此类情况。

更新:这是另一个使用 SAS 数据集而不是来自 LIBNAME 引用的表的(经过测试的)示例。请注意,我还纠正了input函数的语法错误(最后一个参数应该是7.not z7.)。

data ORIGIN;
  DQBBDA = 11130314; output;
  DQBBDA = 22130314; output;
run;
options validvarname=any;
proc sql;
    create table TEST as 
    select DQBBDA AS 'Sbm Date'n
         , case when DQBBDA > 999999
                then input('1' || substr(put(DQBBDA,z8.),3), 7.)
            end as SASDOS format=z7.
    from ORIGIN
    WHERE CALCULATED SASDOS = 1130314;
quit;
于 2013-03-17T13:45:24.283 回答
0

我认为而不是计算 sasdos你应该使用sasdos

于 2013-03-19T17:00:27.543 回答