BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
YannRC
Obsidian | Level 7

Hi,

 

Someone can help me. Why I have a synthax error. I'm surprised to see that Datepart is not colored in Blue. My variable is in date format.

 

It's a FEDSQL

 

YannRC_0-1755170364245.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

LinusH_0-1755588782078.png

Data never sleeps

View solution in original post

7 REPLIES 7
LinusH
Tourmaline | Level 20

You must not have a space between <DATE> and your constant.

Data never sleeps
YannRC
Obsidian | Level 7

YannRC_0-1755183699039.png

 

It's the same result without space. I remove also all the space. Same error.

 

😭

SASKiwi
PROC Star

You are using SAS SQL so the correct way to define a date constant in SAS SQL is: '15Jul2025'd

 

Tom
Super User Tom
Super User

What type of library engine is being used by the OA libref you mentioned in your code snippet? Perhaps FEDSQL is having trouble pushing your WHERE clause into an external database?  

 

NOTE: If the variable has DATE values why are you trying to run DATEPART() function on it?  That only works when the variable has DATETIME values (what other languages call TIMESTAMP values).  DATE values in SAS are number of days since 1960 and DATETIME values are number of seconds.  So passing a DATE value to the DATEPART() function will result in the date of 01JAN1960 (or possibly 31DEC1959 if the date was before 1960).

LinusH
Tourmaline | Level 20

"It's a FEDSQL"

No it's not, you have "proc sql;" in your program.

If you wish to use FedSQL syntax you actually need to use the FedSQL procedure.

Data never sleeps
jennifertaylor
Calcite | Level 5

In FedSQL, the function DATEPART() is not valid, which is why you are getting a syntax error. If your column REPONSE_DATE is already stored as a DATE, you can directly compare it using WHERE t1.REPONSE_DATE = DATE '2025-07-15'. If it is a DATETIME, you should first cast it to a DATE and then compare, for example WHERE CAST(t1.REPONSE_DATE AS DATE) = DATE '2025-07-15'. This will fix your error and run correctly.

LinusH
Tourmaline | Level 20

LinusH_0-1755588782078.png

Data never sleeps

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 7 replies
  • 4436 views
  • 1 like
  • 5 in conversation