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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.