我目前正尝试通过SAS DI自动执行我在SAS EG中编写的一段代码。
虽然它在SAS EG中运行时没有任何问题,但DI在我的Teradata服务器上执行的SQL语句上返回错误。
错误如下:
Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, ',', -,
'.', /, , =, , =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT,
IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.
这是导致错误的行:
SELECT CAST(EV_ID as VARCHAR(20)) AS EV_ID.
这个演员陈述是必要的,因为EV_ID是一个BIGINT,SAS不能用这个字段创建一个表格。
完整代码如下:
proc sql;
connect to teradata (user=&tera_usr pass="&tera_pw" server=tdprod);
CREATE TABLE OVERALL_SAMPLE_TF AS SELECT * FROM connection to teradata(
SELECT A.EV_ID, A.CreatedDate, A.CompletionDate, A.SortCode,
A.SenderBIC, A.ReceiverBIC, A.NumberOfHitsPerAlert,
A.Level1ExecutionUser, A.Level2ExecutionUser, A.Final_Level,
A.Currency, A.Iban, A.Account_Number, A.T_Transaction, A.Last_Operator,
A.MessageID, A.Message_Type, A.Nature, A.Decision_Type, A.Branch_Contact,
A.Other_Bank_Contact, A.CompletionDate_TIMESTAMP,
A.Amount,
B.Franchise, B.Sub_Franchise, B.Sub_Sub_Franchise
FROM
(SELECT X.*,Y.DIV_ID
FROM
( SELECT CAST(EV_ID as VARCHAR(20)) AS EV_ID,
CreatedDate, CompletionDate, SortCode,
SenderBIC, ReceiverBIC, NumberOfHitsPerAlert,
Nonblocking, Level1ExecutionUser, Level2ExecutionUser, Final_Level,
Currency, Iban, Account_Number, T_Transaction, Last_Operator,
MessageID, Message_Type, Nature, Decision_Type, Branch_Contact,
Other_Bank_Contact, CompletionDate_TIMESTAMP,
Amount
FROM BAC_AML.EVENT_STATUS_ALERT_TF WHERE
CompletionDate >= ADD_MONTHS(current_date - EXTRACT(DAY FROM current_date)+1, -1)
AND CompletionDate <= (current_date - extract(day from current_date)+1)-1
AND CompletionDate NE '99991231' (date, format 'yyyymmdd')
AND Final_Level>0
AND UPPER(DECISION_TYPE) IN ('PASS', 'PASS_L1', 'FAIL', 'UNQUEUE', 'RECHECKED')
QUALIFY ROW_NUMBER() OVER (PARTITION BY EV_ID
ORDER BY CompletionDate_TIMESTAMP DESC) = 1
) AS X
LEFT JOIN
(SELECT CAST(EV_ID as VARCHAR(20)) AS EV_ID, CAST(DIV_ID as VARCHAR(20)) AS DIV_ID
FROM BAC_AML.TF_FRANCHISE
) AS Y
ON X.EV_ID=Y.EV_ID
) AS A
LEFT JOIN
(SELECT CAST(FR_KEY as VARCHAR(20)) AS FR_KEY,
L1_Empos_Name, L2_Emp_Posn_Name, L3_Emp_Posn_Name,
L4_Emp_Posn_Name, Franchise, Sub_Franchise, Sub_Sub_Franchise,
ORG_MODEL_LINK
FROM BAC_AML.FRANCHISE_LOOKUP
WHERE UPPER(FRANCHISE) IN ('PBB','CPB','ULSTER','NWM')
) AS B
ON B.FR_KEY=A.DIV_ID;
);
disconnect from teradata;
quit;
请你能帮忙吗?
谢谢。答案 0 :(得分:0)
从"&tera_pw"
中删除双引号,SAS注释here。
正确的行shoule是这样的:
connect to teradata (user=&tera_usr pass=&tera_pw server=tdprod);