BookmarkSubscribeRSS Feed
Lost_Gary
Quartz | Level 8

I have a data field 'TimeStamp' that I've imported via API that appears as 1.7454672E12. The information published states the field is ' Either a date with the format YYYY-MM-DD or a millisecond timestamp.'

 

I'd appreciate any thoughts on a SAS format that can help me understand what this value is. 

Thanks.  

4 REPLIES 4
PaigeMiller
Diamond | Level 26

So your timestamp is about 1.7 trillion, whereas the timestamp of today (April 28, 2025) is approx 2 billion, about 1,000 times smaller than the timestamp you show. So if your timestamp is in milliseconds, then you would divide by 1,000 to turn it into seconds, and then use a datetime format to convert it to a date.

 

data a;
    timestamp=datetime();
    output;
    timestamp=1.7454672E12/1000;
    output;
    format timestamp dtdate9.; /* Or use whatever datetime format you want */
run;

 

 

 

 

--
Paige Miller
Quentin
Super User

Do you know what the correct date or date-time value is, which this value represents?  If it is a millisecond timestamp, is it number of milliseconds since what zero point?

 

If it's number of milliseconds, you could convert it to number of seconds, but you need to know the zero point.  If the  0 is Jan 1, 1960, then it would represent 24Apr2015 at 4:00am:

 

18   data a ;
19     x=1.7454672E12 ;
20     x=x/1000 ;
21     format x datetime19. ;
22     put x= ;
23   run ;

x=24APR2015:04:00:00
NOTE: The data set WORK.A has 1 observations and 1 variables.

 

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
PaigeMiller
Diamond | Level 26

Good point, we don't know the zero point for this information.

 

Minor quibble, which I was going to mention in my other post

 

The value 1.7454672E12 is almost definitely a truncated value, it almost definitely is not the actual time that the timestamp was taken (not a good way to transmit information) because there are only 8 significant digits. So it would represent 24Apr2015 at 4:00am, plus or minus a few hours (which I am too lazy to calculate exactly).

--
Paige Miller
Tom
Super User Tom
Super User

Unix timestamps use 1970 as the base date.

65   data test;
66     ts=1.7454672E12;
67     dt='01JAN1970:00:00'dt + ts/1000;
68     put ts=comma20./ dt=datetime26.6;
69   run;

ts=1,745,467,200,000
dt=24APR2025:04:00:00.000000

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2385 views
  • 3 likes
  • 4 in conversation