DATA Step, Macro, Functions and more

convert eastern datetime to local datetime

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 80
Accepted Solution

convert eastern datetime to local datetime

Hi I have a table that has the time set at eastern time I need it to be local time depending what time zone...
Here is example
STATE. START. END.
TX. 02/07/16 01:59 AM. 02/07/16 02:02 AM


I need that to convert to local texas time..... I can add zip code actually I have a column that has time off set which shows an -60.

Accepted Solutions
Solution
‎05-13-2016 07:08 PM
Respected Advisor
Posts: 4,920

Re: convert eastern datetime to local datetime

You could use an informat to translate the state name into a minute offset :

 

proc format;
invalue timeZone
"TX" = -60
"NY" = 0
OTHER = 0
;
run;

data have;
infile datalines dsd dlm=".";
input STATE :timeZone. (START END) (:MDYAMPM.);
TX_start = intnx("MINUTE",START, STATE);
TX_end = intnx("MINUTE", END, STATE);
format TX_: dateampm.;
datalines;
TX. 02/07/16 01:59 AM. 02/07/16 02:02 AM.
;
PG

View solution in original post


All Replies
Solution
‎05-13-2016 07:08 PM
Respected Advisor
Posts: 4,920

Re: convert eastern datetime to local datetime

You could use an informat to translate the state name into a minute offset :

 

proc format;
invalue timeZone
"TX" = -60
"NY" = 0
OTHER = 0
;
run;

data have;
infile datalines dsd dlm=".";
input STATE :timeZone. (START END) (:MDYAMPM.);
TX_start = intnx("MINUTE",START, STATE);
TX_end = intnx("MINUTE", END, STATE);
format TX_: dateampm.;
datalines;
TX. 02/07/16 01:59 AM. 02/07/16 02:02 AM.
;
PG
Super User
Posts: 11,343

Re: convert eastern datetime to local datetime

Is there any chance you're going to be dealing with Texas times in the El Paso region? El Paso is Mountain Time zone.

 

if you have the SAS supplied SASHELP.Zipcode data set (or download it) there is time offset and daylight savings time information by Zip code that may be of use.

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 248 views
  • 2 likes
  • 3 in conversation