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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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