CREATE table Work.PCGT1 AS
5705 SELECT
5706 POLICY_NUMBER,
5707 Sum(POLICY_COUNT) AS POLICY_COUNT,
5708 FROM WORK.BLCCRF
____
22
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, ^=, |, ||, ~=.
5709 GROUP BY POLICY_NUMBER
_____
22
76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,
AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM, GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH,
LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
5710 HAVING POLICY_COUNT > 1
5711 ;
I'm having trouble debugging this simple program. And for some additional information the Work.BLCCRF table does exist and has been referenced in previous blocks of code that ran fine. And every field that I'm calling is spelled correctly. What seems to be the problem?
Remove this comma:
AS POLICY_COUNT,
Wow that's it I really thought I needed that comma there. Thank you!
You have an extra comma.
If find it is much easier for humans to review code when such continuation characters are placed at the beginning of the line instead of the end (where even if they stay on the screen are not going to be in your natural line of sight).
CREATE table Work.PCGT1 AS
SELECT POLICY_NUMBER
, Sum(POLICY_COUNT) AS POLICY_COUNT
FROM WORK.BLCCRF
GROUP BY POLICY_NUMBER
HAVING POLICY_COUNT > 1
;
Also which version of POLICY_COUNT are you expecting the HAVING clause to reference? The original variable or the one that is being calculated with the SUM() aggregate function?
Please mark the question answered, by selecting one of the responses (not this one!) that answers your question.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.