Help using Base SAS procedures

Need to find timezone

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 114
Accepted Solution

Need to find timezone

I have a table thst has
City state zip lat long
I need to find the time zone base of these col for example
Central...


Thanks for assistance

Accepted Solutions
Solution
‎02-15-2018 12:13 PM
Super User
Posts: 13,523

Re: Need to find timezone

You may actually have a dataset installed named SASHELP.ZIPCODE which has that information including city names (and some alternate names as well), state zipcode and lat and long though those may not match.

 

The question may be are your zips 5 or 5+4?

The ZIP in sashelp.zipcode is numeric so matching may require adjusting values.

 

Assuming your zip are numeric and of the classic 5 number variety:

proc sql;
   create table tz as
   select a.*, b.timezone, b.gmtoffset
   from youdata as a
       left join
       sashelp.zipcode as b
       on a.zip=b.zip;
quit;

If you zip is a 5 character with leading 00 as needed then

 

proc sql;
   create table tz as
   select  a.*, b.timezone, b.gmtoffset
   from youdata as a
       left join
       sashelp.zipcode as b
       on a.zip= put(b.zip,z5.);
quit;

View solution in original post


All Replies
PROC Star
Posts: 1,283

Re: Need to find timezone

I don't think SAS has such a functionality directly, but below is a link to a data base that links latitude and longitude to time zones 

 

https://boutell.com/zipcodes/

 

 

Solution
‎02-15-2018 12:13 PM
Super User
Posts: 13,523

Re: Need to find timezone

You may actually have a dataset installed named SASHELP.ZIPCODE which has that information including city names (and some alternate names as well), state zipcode and lat and long though those may not match.

 

The question may be are your zips 5 or 5+4?

The ZIP in sashelp.zipcode is numeric so matching may require adjusting values.

 

Assuming your zip are numeric and of the classic 5 number variety:

proc sql;
   create table tz as
   select a.*, b.timezone, b.gmtoffset
   from youdata as a
       left join
       sashelp.zipcode as b
       on a.zip=b.zip;
quit;

If you zip is a 5 character with leading 00 as needed then

 

proc sql;
   create table tz as
   select  a.*, b.timezone, b.gmtoffset
   from youdata as a
       left join
       sashelp.zipcode as b
       on a.zip= put(b.zip,z5.);
quit;
☑ This topic is solved.

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

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