BookmarkSubscribeRSS Feed
india2016
Pyrite | Level 9

03JAN2011:00:00:00.000

which format should I use to read this date ?

 

6 REPLIES 6
art297
Opal | Level 21

Depends upon what you want. That is a datetime, not a date. If you want to capture all three you could use something like:

data have;
  input dt datetime22.;
  format date date9.;
  format time time5.;
  date=datepart(dt);
  time=timepart(dt);
  cards;
03JAN2011:00:00:00.000
;

Art, CEO, AnalystFinder.com

 

ChrisBrooks
Ammonite | Level 13

You need an informat to read data not a format - try datetime22. (Untested)

ballardw
Super User

If all of the values have the same "time", especially of :00:00:00.000 I would use a DATE9. informat to read the date and discard the time part.

Don't forget to set a display format so humans can see the date in a useable form.

Reeza
Super User

When in doubt try ANYDTDTM for datetime and ANYDTDTE for dates.

ChrisBrooks
Ammonite | Level 13
The only note of caution I'd sound about ANYDTDTM and ANYDTDTE is that they are dependant on the correct Locale being set. I learned that the hard way a few years ago when working on a server in the U.K. where unknown to me the Locale had been set to US which led to some correct dates, some incorrect dates and some errors. It puzzled me for quite a while before I realised what was going on.....
india2016
Pyrite | Level 9

Thanks, everyone

 

 

.

I used Datetime22.3 format and it successfully reads that observation.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1542 views
  • 2 likes
  • 5 in conversation