BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Hi guys

it shows 1jan1960 instead of today date

data w;
n=today(); 
format n  dtdate9.;
run;
2 REPLIES 2
Kurt_Bremser
Super User

MAXIM 1: Read the Documentation!

 

From the documentation of the DTDATE format:

 

Expects a datetime value as input and writes date values in the form ddmmmyy or ddmmmyyyy.

 

(emphasis by me).

Tom
Super User Tom
Super User

@BrahmanandaRao wrote:

Hi guys

it shows 1jan1960 instead of today date

data w;
n=today(); 
format n  dtdate9.;
run;

SAS stores dates as number of days and datetime values as number of seconds.

What date do you think 22 thousand seconds into the year 1960 represents?

For a hint open this "spoiler".

 

Spoiler

 

424   data _null_;
425     days=date();
426     seconds=datetime();
427     put 'DAYS    ' (4*days) (comma15. +1 date9. +1 dtdate9. +1 tod8.);
428     put 'SECONDS ' (4*seconds) (comma15. +1 date9. +1 dtdate9. +1 tod8.);
429   run;

DAYS             22,625 11DEC2021 01JAN1960 06:17:05
SECONDS   1,954,840,911 ********* 11DEC2021 11:21:51

 

 

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