BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Akhila1
Fluorite | Level 6

Please help me to convert the following SAS date to mmddyy10.

1955664000

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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;

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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.

 

 

Akhila1
Fluorite | Level 6
It is a number. Date time.
PaigeMiller
Diamond | Level 26

@Akhila1 wrote:
It is a number. Date time.

Tell us specifics. What date? What time?

--
Paige Miller
SASKiwi
PROC Star

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 842 views
  • 0 likes
  • 4 in conversation