Please help me to convert the following SAS date to mmddyy10.
1955664000
Thanks
Are you sure that number is a SAS date? It looks more like a datetime to me. As a SAS date it is 1.9 billion days after 1 Jan 1960 or 5.4 million years.
data want;
format MyDate MyDate2 mmddyy10.;
MyDate = datepart(1955664000);
MyDate2 = 1955664;
put _all_;
run;
Is that a string?
string='1955664000';
Or a number?
number=1955664000;
If it is a number does it have any display format attached to it?
What date does 1955664000 represent?
It is clearly not in YYMMDD style since there is no month number 66 in the year 1955.
Is it possible it is a DATETIME value (number of seconds) and not a DATE value (number of days) at all? That number of seconds would be in the year 2021.
129 data test; 130 number=1955664000 ; 131 put number=comma20. number :datetime19. ; 132 run; number=1,955,664,000 21DEC2021:00:00:00
If so you might want to just use the DATEPART() function to covert the number of seconds into number of days. Then you could attach the MMDDYY10. format and it would work.
Also why would you want to display the date in MDY (or DMY) order? Either choice will confuse half of your audience.
If you want to display it in ddMONyyyy style you could use the DTDATE9. format with the existing datetime value.
Are you sure that number is a SAS date? It looks more like a datetime to me. As a SAS date it is 1.9 billion days after 1 Jan 1960 or 5.4 million years.
data want;
format MyDate MyDate2 mmddyy10.;
MyDate = datepart(1955664000);
MyDate2 = 1955664;
put _all_;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.