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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.