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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.