首页 > 解决方案 > 使用直通执行 SAS 代码时出错

问题描述

我正在尝试运行下面的代码,但它返回错误,我已经检查了语法,它似乎没有错,但错误仍然存​​在

proc sql;
       connect to oracle as BD (user = &varUserDBRtdbm. 
                                password = &varPassDBRtdbm.
                                path = &varPathRtdbmProd.);
               select *
                           from connection to BD
                               (select * 
                                   from (select *
                                           from rtdbm.base_atendimento
                                               where trim(dat_abertura) not in ('NA', 'A')
                                                   and UPPER(trim(cod_caso)) not in ('123','N/A','NA','DIGITAL', '001','NULL','DIGITAL','TESTE','LUCAS')
                                                   and trunc(to_date(dat_abertura,'DD/MM/RRRR HH24:MI:SS'))       >= to_date('01/08/2020','DD/MM/RRRR HH24:MI:SS')
                                                   ) a,
                                                   rtdbm.base_oferta b
                                                       where a.cod_caso = b.cod_caso) BY BD;
       disconnect from BD;
   quit;

出现的部分错误:

                                                      ) a,
66                                                      rtdbm.nba_tra_oferta b
67                                                          where a.cod_caso = b.cod_caso) BY BD;
                                                          __
                                                          22
                                                          76
ERROR 22-322: Syntax error, expecting one of the following: ',', GROUP, HAVING, ORDER, WHERE.  

ERROR 76-322: Syntax error, statement will be ignored.

标签: sas

解决方案


去除BY BD

您的代码是结构化的

select * from connection to BD 
(
  ...
)
by BD;

by <connection>用于Proc SQL EXECUTE声明,此处不需要。


推荐阅读