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
You must not have a space between <DATE> and your constant.
It's the same result without space. I remove also all the space. Same error.
😭
You are using SAS SQL so the correct way to define a date constant in SAS SQL is: '15Jul2025'd
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).
"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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.