Hi
Does SAS EG 4.3 using Windows XP Pro have access to a Function for converting Epoch times to date/time format?
If not, how do I change an Epoch time over? Thanks
PcFriendly
I don't know of a function but all you have to do is add the UNIX epoch start (converted to SAS sas time) and add that to your unix time in seconds and adjust for time zone.
I collect some time data using this command and pasted a few lines of the output into the following data step.
find . -name "*.sas" -printf "%a %A@\n"
data _null_;
input dt $1-24 sec1970;
unixEpoch = dhms('01jan1970'd,0,0,0);
GMTsasDT = sec1970 + unixEpoch;
PDTsasDT = GMTsasDT - dhms(0,7,0,0);
put dt= (GMT: PDT:) (=datetime.) sec1970=;
cards;
Thu Jul 5 15:03:31 2012 1341525811
Tue Jul 10 11:38:38 2012 1341945518
Tue Jul 10 14:33:26 2012 1341956006
run;
2191 data _null_;
2192 input dt $1-24 sec1970;
2193 unixEpoch = dhms('01jan1970'd,0,0,0);
2194 GMTsasDT = sec1970 + unixEpoch;
2195 PDTsasDT = GMTsasDT - dhms(0,7,0,0);
2196 put dt= (GMT: PDT:) (=datetime.) sec1970=;
2197 cards;
dt=Thu Jul 5 15:03:31 2012 GMTsasDT=05JUL12:22:03:31 PDTsasDT=05JUL12:15:03:31 sec1970=1341525811
dt=Tue Jul 10 11:38:38 2012 GMTsasDT=10JUL12:18:38:38 PDTsasDT=10JUL12:11:38:38 sec1970=1341945518
dt=Tue Jul 10 14:33:26 2012 GMTsasDT=10JUL12:21:33:26 PDTsasDT=10JUL12:14:33:26 sec1970=1341956006
I don't know of a function but all you have to do is add the UNIX epoch start (converted to SAS sas time) and add that to your unix time in seconds and adjust for time zone.
I collect some time data using this command and pasted a few lines of the output into the following data step.
find . -name "*.sas" -printf "%a %A@\n"
data _null_;
input dt $1-24 sec1970;
unixEpoch = dhms('01jan1970'd,0,0,0);
GMTsasDT = sec1970 + unixEpoch;
PDTsasDT = GMTsasDT - dhms(0,7,0,0);
put dt= (GMT: PDT:) (=datetime.) sec1970=;
cards;
Thu Jul 5 15:03:31 2012 1341525811
Tue Jul 10 11:38:38 2012 1341945518
Tue Jul 10 14:33:26 2012 1341956006
run;
2191 data _null_;
2192 input dt $1-24 sec1970;
2193 unixEpoch = dhms('01jan1970'd,0,0,0);
2194 GMTsasDT = sec1970 + unixEpoch;
2195 PDTsasDT = GMTsasDT - dhms(0,7,0,0);
2196 put dt= (GMT: PDT:) (=datetime.) sec1970=;
2197 cards;
dt=Thu Jul 5 15:03:31 2012 GMTsasDT=05JUL12:22:03:31 PDTsasDT=05JUL12:15:03:31 sec1970=1341525811
dt=Tue Jul 10 11:38:38 2012 GMTsasDT=10JUL12:18:38:38 PDTsasDT=10JUL12:11:38:38 sec1970=1341945518
dt=Tue Jul 10 14:33:26 2012 GMTsasDT=10JUL12:21:33:26 PDTsasDT=10JUL12:14:33:26 sec1970=1341956006
Thanks data_null_;
I'll give it a try. :smileygrin:
How do I mark this question as answered?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.