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

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 247 views
  • 0 likes
  • 3 in conversation