BookmarkSubscribeRSS Feed
kartheekm9
Calcite | Level 5

I'm trying to create a table using proc sql with date(in DATE9. format) as on of the column.

I'm trying to filter the data using where on the date column in the proc sql. I want to have today's date in the condition.

My code looks like:

 

PROC SQL;
create table work.sheet as
select a, b, date

from library

where date>= '02-01-2018' and date <= today();

quit;

 

The error message says;

SQL0440N No authorized routine named "TODAY" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884

 

it works well when I use, where date>= '02-01-2018' and date <= '05-31-2019';

 

Can someone help me on this?

 

Thank you.

9 REPLIES 9
PaigeMiller
Diamond | Level 26
where date>= '01FEB18'd and date <= "&sysdate"d;
--
Paige Miller
kartheekm9
Calcite | Level 5

Thank you Paige for the prompt reply. I'm still getting an error though:

 

SQL0104N An unexpected token "d" was found following "date <="21JUN19"". Expected tokens may include: "<update_source_no_row_query>". SQLSTATE=42601

 

I removed the d as it was saying, and still got an error:

 

SQL0206N "21JUN19" is not valid in the context where it is used. SQLSTATE=42703

PaigeMiller
Diamond | Level 26

The error message as it appears in your last message is meaningless to us unless we can see the code you are using. So ...

 

Show us a portion of your data.

 

Show us the full SASLOG, not just the error messages, and please paste the log into the window that appears when you click on the {i} icon; do not show us the SASLOG any other way.

--
Paige Miller
Kurt_Bremser
Super User

I guess this happens because of the way the implicit pass-through works. What happens if you use today() as the upper bound?

 

Edit: forget it. You already got a complaint for that in your first post.

kartheekm9
Calcite | Level 5
No luck with that too,

ERROR: CLI describe error: [IBM][CLI Driver][DB2/AIX64] SQL0440N No authorized routine named "TODAY" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884
ballardw
Super User

@kartheekm9 wrote:

Thank you Paige for the prompt reply. I'm still getting an error though:

 

SQL0104N An unexpected token "d" was found following "date <="21JUN19"". Expected tokens may include: "<update_source_no_row_query>". SQLSTATE=42601

 

I removed the d as it was saying, and still got an error:

 

SQL0206N "21JUN19" is not valid in the context where it is used. SQLSTATE=42703


One suspects that you are connecting to an external DBMS and that the message is from the other system, MS SQL Server perhaps?

If you are using Pass through SQL then your syntax needs to conform to the external system.

 

 

anushreebiotech
Obsidian | Level 7

Hello,

 

Please check this:

 

PROC SQL;
create table work.sheet as
select a, b, date

from library

where date>= '02-01-2018'd and date <= today();

quit;

 

It worked for me.

 

Regards,

Anushree

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Welcome to the world of dealing with dates. This link may help you in understanding what the hay today() is and how you can use it.

https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm

You do have to put on your thinking cap when working with dates in any programming language.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 9 replies
  • 3391 views
  • 1 like
  • 6 in conversation