BookmarkSubscribeRSS Feed
Arun_shSAS
Fluorite | Level 6

Hi All,

I am running below Teradata code using passthrough but facing some error:

 

SELECT *
FROM ABC LEFT JOIN BCD on A.ABC = B.BCD
WHERE MONTH > concat( cast(extract(year from add_months((DATE - extract(day from DATE)) ,-9)) as varchar(4)), SUBSTR(cast(100 + extract( month from add_months((DATE - extract(day from DATE)) ,-9)) as varchar (3)) ,2 ,2) )

 

I am not sure if we can use add_months in SAS, if not how can we resolve this?

4 REPLIES 4
LinusH
Tourmaline | Level 20

Always (always!) when you run into problem with code, show the log!

And given that this is pass-thru, usually it's not a SAS issue.

But are you tring to use something from the local SAS session?, not clear from your post.

Data never sleeps
RW9
Diamond | Level 26 RW9
Diamond | Level 26

So which is it?  You say you are using passthrough, if so this piece of code you present here will be sent to the database, and the database will execute it.  Therefore it will use the functions available to the database.

You then proceed to say that you can't use add_months in SAS, which is true as add_months is not a SAS function, but as the code is not being run in SAS per your first statement, this is not relevant?

Please clarify what you mean, where is the code running, what logs you get etc.

Arun_shSAS
Fluorite | Level 6

Yes, this is the teradata script i am running and expecting all the teradata function like add_month, cast can run through pass through.

 

Error : 

ERROR: Teradata execute: Syntax error: expected something between '('
and cast.

 

LinusH
Tourmaline | Level 20
Still, where's the (complete) log?
Given the code you presented you are/should use explicit pass through. And then your syntax problem is something for a Teradata forum to help you with.
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

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
  • 4 replies
  • 1479 views
  • 0 likes
  • 3 in conversation