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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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