BookmarkSubscribeRSS Feed
Luth
Calcite | Level 5

I am a relatively new user of SAS EG, and I've run into a problem that I cannot find an answer to.  The data I'm querying against uses a field called "GROUP" that I need to pull into my query, but EG won't let me because it considers GROUP a keyword.  If I was using PC SAS, I know I could bracket [GROUP] and it would work, but I can't figure out how to get around this problem.  I'm getting a error stating Incorrect syntax near the keyword 'GROUP' whenever I attempt to use the GROUP field in my query.

I'm not the owner of the source data, so I cannot simply change the field name.  Any suggestions?

5 REPLIES 5
art297
Opal | Level 21

I am NOT an EG expert, but I had no problem, just now, including a variable called GROUP, in the query builder, as either a selection item, a group item or the target of a query.

Of course, if you do have a problem doing it, can't you just include code, before that, that opens the original file and makes a copy of it, renaming the variable?

Reeza
Super User

What's your version of EG?

And you can you post what the code/log displays.

Also, Tech Support may be faster.

Luth
Calcite | Level 5

I'm using version 4.1 - here is the code and log I'm getting back:

PROC SQL; CREATE TABLE SASUSER.Query_for_tblClaims_2012_Q3 AS SELECT tblClaims_2012_Q3.GROUP, (COUNT(tblClaims_2012_Q3.RXNUM)) AS COUNT_OF_RXNUM

FROM CLMSWHSE.tblClaims_2012_Q3 AS tblClaims_2012_Q3

WHERE tblClaims_2012_Q3.DOF = '15JUL2012'd AND tblClaims_2012_Q3.CLMSTAT = "P"

GROUP BY tblClaims_2012_Q3.GROUP;

QUIT;

ERROR: CLI prepare error: [DataDirect][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'GROUP'. :        [DataDirect][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. SQL statement: SELECT   GROUP ,  RXNUM ,  DOF ,  CLMSTAT   FROM  dbo . tblRxClaim_2012_Q3   WHERE  ( (  DOF  = {d '2012-07-15' } )        AND  (  CLMSTAT  = 'P' ) ). ERROR: PROC SQL runtime error for operation=sqxsrc. ERROR: An error has occurred.

art297
Opal | Level 21

I agree wth Fareeza .. this looks like one that would be most quickly addressed by tech support.  It appears to be a problem in what is being sent to SQL server.

Luth
Calcite | Level 5

Thank you for your advice - I'll take this one to tech support.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 2524 views
  • 0 likes
  • 3 in conversation