Hi guys
it shows 1jan1960 instead of today date
data w;
n=today();
format n dtdate9.;
run;
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).
@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".
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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.