Hello I am working on a code and keep getting this error, not sure what is causing it
Proc sql;
Create table visit_count as
select distinct
a.ayb_id,
a.VisitCnt as Visits,
from aybdata.portal_reg as a
and sum(VisitCnt) as sum_visits
where calculated sum_visits >= 2
group by a.ayb_id, a.VisitCnt
order by a.ayb_id;
quit;
388 + from aybdata.portal_reg as a and
_______ ___
22 76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.
Please post the entire portion of the log with the code and error messages as sometimes the cause is actually some where earlier in the code. Also post them into a code box using the forum {i} icon as the postion dependent indicators get moved when pasted into a main message window.
You have at least one SUM function in a place not allowed. SUM is only acceptable in SELECT or HAVING clauses
Did you want this?
proc sql;
create table visit_count as
select distinct
a.ayb_id,
a.VisitCnt as Visits,
sum(VisitCnt) as sum_visits
from aybdata.portal_reg as a
where calculated sum_visits >= 2
group by a.ayb_id, a.VisitCnt
order by a.ayb_id;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.