Desktop productivity for business analysts and programmers

EPOCH Time conversion

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 80
Accepted Solution

EPOCH Time conversion

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 


Accepted Solutions
Solution
‎07-11-2012 08:55 AM
Respected Advisor
Posts: 3,788

Re: EPOCH Time conversion

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: PDTSmiley Happy (=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: PDTSmiley Happy (=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

View solution in original post


All Replies
Solution
‎07-11-2012 08:55 AM
Respected Advisor
Posts: 3,788

Re: EPOCH Time conversion

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: PDTSmiley Happy (=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: PDTSmiley Happy (=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

Frequent Contributor
Posts: 80

Re: EPOCH Time conversion

Thanks data_null_;

I'll give it a try.  :smileygrin:

Frequent Contributor
Posts: 80

Re: EPOCH Time conversion

How do I mark this question as answered?

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 1990 views
  • 1 like
  • 2 in conversation