BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pcfriendly
Calcite | Level 5

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 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

View solution in original post

3 REPLIES 3
data_null__
Jade | Level 19

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

pcfriendly
Calcite | Level 5

Thanks data_null_;

I'll give it a try.  :smileygrin:

pcfriendly
Calcite | Level 5

How do I mark this question as answered?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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