Desktop productivity for business analysts and programmers

converting numbers to time format

Reply
Super Contributor
Super Contributor
Posts: 404

converting numbers to time format

I have one numeric value (below) as time and description of the value is "in seconds since the epoch". 

would I able to convert it into hh:mm:ss? - Thanks.

 

1510949673

 

 

 
Super User
Posts: 22,850

Re: converting numbers to time format

Sounds like that’s a date time. Do you know what the date of 'epoch' is?

 

Try to apply the datetime format. If it shows a date and time you expect you can use TIMEPART to extract the relevant time portion. 

 

Proc print data =have;
Format variable datetime.;

Time_portion = timepart(variable);
Super User
Posts: 9,593

Re: converting numbers to time format

This might be a UNIX timestamp, in which case you need to add the difference between 01jan1960 and 01jan1970 to correctly display in SAS.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 2 replies
  • 155 views
  • 0 likes
  • 3 in conversation