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

Hi,

I have this number 44824.689149 in sas table. If I put this it into an excel and format it in date time I get the following result is 20/09/2022 16:32:22.

 

How can I do this in sas?

I try with

 

data test;
a=put(44824.689149,datetime16.);
run;

but I get: 01jan60:12:27:05

 


Thanks,

Luca

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Excel counts days from a different starting point.  Excel stores time of day as a fraction of a day. You can use the DHMS() function to days (including fractional days) into datetime.

data test;
  datetime=dhms('30DEC1899'd+44824.689149,0,0,0);
  format datetime datetime19.;
run;
317  data test;
318    datetime=dhms('30DEC1899'd+44824.689149,0,0,0);
319    format datetime datetime19.;
320    put datetime=;
321  run;

datetime=20SEP2022:16:32:22

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Excel counts days from a different starting point.  Excel stores time of day as a fraction of a day. You can use the DHMS() function to days (including fractional days) into datetime.

data test;
  datetime=dhms('30DEC1899'd+44824.689149,0,0,0);
  format datetime datetime19.;
run;
317  data test;
318    datetime=dhms('30DEC1899'd+44824.689149,0,0,0);
319    format datetime datetime19.;
320    put datetime=;
321  run;

datetime=20SEP2022:16:32:22
abaker_ca
Obsidian | Level 7
I just posted this exact same problem with my own data set and then found your solution. Thank you!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 2315 views
  • 1 like
  • 3 in conversation