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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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