BookmarkSubscribeRSS Feed
Mary001
Fluorite | Level 6

Hi All,

 

I have a proc sql (SAS EG 7.1) and in the where clause is a date variable but instead of putting a hard date, I would like to use something similar to the intnx function to dynamically get the previous month's date.

 

Users will be running the sql at any given time and it should always use the previous EOM date.

 

here's what I have now ...

select *

from abc

where date = '1/31/2020'

 

I've tried this and get this error, SQL0440N No authorized routine named "TODAY" of type "FUNCTION"
having compatible arguments was found. SQLSTATE=42884 

 

select *

from abc

where date = intnx('month',today(),-1,e)

 

I hope this is something simple, can someone please help? Thank you so much in advance!

 

6 REPLIES 6
Kurt_Bremser
Super User

SQL0440N is a IBM DB/2 ERROR code, so this happens in a piece of explicit pass-through code. In explicit pass-through, you have to use the syntax of the target DBMS.

novinosrin
Tourmaline | Level 20

Hi @Mary001  I tested the below(your code) and it seems to work fine

 

proc sql;
select *

from abc

where date = intnx('month',today(),-1,'e');
quit;
PaigeMiller
Diamond | Level 26

Is your SQL trying to extract from a database via a passthru? Can you show us the entire PROC SQL and not selected parts?

 

The TODAY() function does not work with most databases in a passthru.

--
Paige Miller
Mary001
Fluorite | Level 6

Hi All,

 

Yes, the sql is going to a db2 database to get the filtered data.

 

"The TODAY() function does not work with most databases in a passthru." = Does this mean I need to find a db2 solution?

Kurt_Bremser
Super User

@Mary001 wrote:

Hi All,

 

Yes, the sql is going to a db2 database to get the filtered data.

 

"The TODAY() function does not work with most databases in a passthru." = Does this mean I need to find a db2 solution?


Absolutely. As soon as you enter explicit pass-through, you (temporarily) leave the world of SAS.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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