Can anybody help me to convert EPOCH date to human redable date format ?
for example epoch date 1409071482460 should look like 8/26/2014.
Thanks
Anand
This is a short program I wrote to show the time and date of a UNIX timestamp (helps me to determine if someone's password has expired etc):
data times (keep=x date time);
x = 1398435549; * the UNIX timestamp;
days = int(x / 86400);
time = x - days * 86400;
date = '01jan1970'd + days;
format
date mmddyy10.
time time5.
;
label
x = "Timestamp"
date = "Date"
time = "Time (GMT)"
;
run;
proc print data=times noobs label;
var x date time;
run;
Very helpful.
I encountered the same problem while integrating data from Mongo DB to SAS.
A more easy way, the epoch and sas datetime type only are different in the choicen point of zero. SAS is using 1 jan1960, the epoch is using 1 jan1970. Unix time - Wikipedia, the free encyclopedia - SAS(R) 9.4 Language Reference: Concepts, Third Edition (date time). The conversion is adjusting the time-measure for the point of zero. Giving this datetime variable a SAS format you like you can get every lay-out presented.
data times2;
x = 1398435549; * the UNIX timestamp;
datetm=x+"01jan1970 0:0:0"dt ;
Format datetm datetime. ;
run;
proc print;
run;
It just occured to me that he could use a different epoch than the ones we are used to. 1409071482460 is 3 digits longer.
Could it be that it needs a decimal.
32 GOPTIONS ACCESSIBLE;
33 data _null_;
34 x = 1409071482.460 + '01JAN1970:00:00:00'dt;
35 *should look like 8/26/2014.;
36 put x=datetime25.3;
37 run;
x=26AUG2014:16:44:42.460
Yep you are right, http://www.epochconverter.com/ older system 32-bit are based on seconds, newer systems using the "long epoch" are using fields in milliseconds.
IF this "long epoch" is read binary or as decimal to get seconds divide by 1000. Checked his long number and it is a "long epoch". 26aug2014:16:44:22
Current Millis - convert millis to date and time, live UTC time
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.