Hi Expert,
I am not sure about the syntax error. I think my code is correct but getting error.
proc sql;
create table Chase_Linked as
select distinct *
from Address_Check
where accountstatus = 'Campaign','Chase','Chase Hold','Paying';
create table Chase_Linked2 as
select distinct *,
sum(Postcode_Check) as Acc_Check,
count(debt_code) as Linked_Count
from Chase_Linked
group by icustomerid;
create table Chase_Linked3 as
select distinct *,
case when sum(Acc_Check) = sum(Linked_Count) then 'Y' else 'N'
end as Cust_Check
from Chase_Linked2
group by icustomerid;
create table Trace_Chase_Linked as
select distinct(Trace_Acc),
Trace_Rep,
Trace_Status
from Chase_Linked3
where Cust_Check = 'Y';
quit;
Error log:
30 proc sql;
31 create table Chase_Linked as
32 select distinct *
33 from Address_Check
34 where accountstatus = 'Campaign','Chase','Chase Hold','Paying';
_
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, AND, EQ, EQT, EXCEPT,
GE, GET, GROUP, GT, GTT, HAVING, INTERSECT, LE, LET, LT, LTT, NE, NET, NOT, OR, ORDER, OUTER, UNION, ^, ^=, |, ||, ~,
~=.
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
35
36 create table Chase_Linked2 as
37 select distinct *,
38 sum(Postcode_Check) as Acc_Check,
39 count(debt_code) as Linked_Count
40 from Chase_Linked
41 group by icustomerid;
NOTE: Statement not executed due to NOEXEC option.
Can you please check the code and error log to find it?
You must use the IN operator to compare a value with a list:
where accountstatus in ('Campaign','Chase','Chase Hold','Paying')
You must use the IN operator to compare a value with a list:
where accountstatus in ('Campaign','Chase','Chase Hold','Paying')
Thank you for your response and I did the way you suggested but still getting this error.
30 proc sql;
31 create table Chase_Linked as
32 select distinct *
33 from Address_Check
34 where accountstatus in 'Campaign','Chase','Chase Hold','Paying';
__________ _
22 79
ERROR 22-322: Syntax error, expecting one of the following: (, SELECT.
ERROR 79-322: Expecting a ).
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
Look at the code I gave you and pay attention to details. It is obvious from the ERROR message you got, the message literally tells you what's missing.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.