BookmarkSubscribeRSS Feed
GN0001
Barite | Level 11

Hello team,

 

I have a date column whose date type is numeric, it is as: 7/20/2020

I want to place this date in a where clause.

 Where date = '20Jul2020'd;

This doesn't bring any rows. 

What is the reason?

 

Thanks,

blue blue

Blue Blue
3 REPLIES 3
PaigeMiller
Diamond | Level 26

In addition to @Kurt_Bremser's request, please provide examples of typical values of the variable DATE that you are working with, and the FORMAT of the variable DATE.

--
Paige Miller
Kurt_Bremser
Super User

If this data was imported from Excel, you might have "hidden" time information in it, because Excel stores times as fractions of a day, not counts as seconds.

As illustration run this short code and look at the log:

data _null_;
format date mmddyy10.;
date = '20Jul2020'd;
put "date as is " date;
if date = '20Jul2020'd then put "yes";
date = date + .1;
put "date after addition " date;
if date = '20Jul2020'd then put "yes"; else put "no";
run;

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

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