BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
d6k5d3
Pyrite | Level 9

I have a Year column and a Date column. For a particular year, I want to delete a few dates. I was trying the following code, but not getting what I expect:

 

data aaa;
set bbb;
if year= 2007 and date in ('03/13/2007'd, '03/14/2007'd) then delete;
run;

I was getting the following error:

 

ERROR: Invalid date/time/datetime constant '03/13/2007'd.
ERROR: Invalid date/time/datetime constant '03/14/2007'd.
ERROR 77-185: Invalid number conversion on '03/14/2007'd.

 

Where did I go wrong? What should I do?

 

Much thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Work with DATE only (not YEAR) but in a different form:

 

if date in ('13MAR2007'd, '14MAR2007'd) then delete;

View solution in original post

3 REPLIES 3
Astounding
PROC Star

Work with DATE only (not YEAR) but in a different form:

 

if date in ('13MAR2007'd, '14MAR2007'd) then delete;

d6k5d3
Pyrite | Level 9
Awesome! Thank you!
Tom
Super User Tom
Super User

The value inside the quotes of a datetime literal (constant) must be in a format that the DATE informat understands.

'01JAN2017'd
'01-JAN-2017'd
"1Jan17"d

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 563 views
  • 1 like
  • 3 in conversation