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?
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?
What's your version of EG?
And you can you post what the code/log displays.
Also, Tech Support may be faster.
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.
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.
Thank you for your advice - I'll take this one to tech support.
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!
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.