BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
izzytetteh24
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Remove this comma:

 

AS POLICY_COUNT,

View solution in original post

6 REPLIES 6
Astounding
PROC Star

Remove this comma:

 

AS POLICY_COUNT,

izzytetteh24
Calcite | Level 5

Wow that's it I really thought I needed that comma there. Thank you!

TonyLMayo
Fluorite | Level 6
Please remove the extra comma between the last variable and the from
statement.
izzytetteh24
Calcite | Level 5
I did it worked out. Thank you 🙂
Tom
Super User Tom
Super User

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?

Reeza
Super User

Please mark the question answered, by selecting one of the responses (not this one!) that answers your question. 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1302 views
  • 3 likes
  • 5 in conversation