BookmarkSubscribeRSS Feed
MSK4
Obsidian | Level 7

proc sql;

connect to oracle as myconn(user=xx pass=xx path=xx);

select * from connection to myconn

(

select * from tranx where datepart(trandate)=intnx('month',trandate,-3)

);

disconnect from myconn;

quit;

Throwing error invalid intnx identifier

Please help me out. Many thanks;

2 REPLIES 2
tarheel13
Rhodochrosite | Level 12

Like @Kurt_Bremser said https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-INTNX-in-Proc-SQL-gives-error/td-p/472356 "In an explicit pass-through, you need to use functions that the target database understands. intnx is not a function in Oracle SQL."

Kurt_Bremser
Super User

When you use explicit pass-through, you must work in the remote environement, which means in your case strict Oracle syntax. Neither the DATEPART nor the INTNX function are available in Oracle, so you need to use the respective Oracle functions for that. Datetime to date will probably be a cast. Also keep in mind that databases use a different system of literals for dates etc.

 

And you need to review your logic. This condition will never be true during the existence of the universe:

datepart(trandate)=intnx('month',trandate,-3)

A date can never be equal to the same date minus three months, and if you need to use DATEPART because trandate is a datetime, then you need to use it in other places also.

The INTNX function does also allow datetime related intervals, like dtmonth, which would allow you to use the datetime directly, but ONLY IN SAS!

 

I suggest that you test your query first in the native Oracle client, and once it works there, see how you can send it from SAS.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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