BookmarkSubscribeRSS Feed
dhir
Obsidian | Level 7

Hi, I have a dataset where variable 'Timestamp' has observations like 

 

15189430314595
15443763999343
15443763999343
15486949615495

 

in a sequence. This is in nanoseconds as per the description of the database. 

I want to convert these variables in date (mm/dd/yyyy) & time (hh:mm:ss) format. 

 

Thanks in advance. 

 

 

1 REPLY 1
Kurt_Bremser
Super User

It is essential to know the cutoff timestamp (the moment when 0 nanoseconds were registered).

With this knowledge, you can do the calculation:

seconds = nanoseconds / 1000000000

and then correct for a zero-point that is different from the zero-point of SAS (01jan1960:00:00:00)

 

As your numbers are rather small, I suspect that you don't really have nanoseconds

(milli - 1/1000th

micro - 1/1000000

nano - 1/1000000000)

If your values were really nanoseconds, they would just describe a time value between 4:13:09 and 4:18:07. No datetimes here.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1928 views
  • 0 likes
  • 2 in conversation