SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Suzy_Cat
Pyrite | Level 9

Hello,

 

Can anyone share their experience in calculating distance between two nz addresses?

 

I had a quick browse and have no clue how to set up/access API.

 

Sad that SASHELP.ZIPCODE has no such info for New Zealand.

 

Would be great to get the practical idea on how to actually using SAS to calculate the distance/travel time required between two address vars.

 

Thanks

 

1 REPLY 1
Reeza
Super User

If you need travel distance it keeps a bit more complicated, you'll need to send your data to a service to get the distance, such as Google Maps, OpenStreetMaps, ESRI. Then it will return the distance.

 

This unfortunately isn't a simple straightforward few lines of code that anyone can provide, especially since Google has now restricted their API and you need a full developer set up to get that going which is a major pain. It also means you are sending your data to an external data provider which could violate privacy regulations. If you want to go down this route, search lexjansen.com for example code, but most may be out of date due to the recent changes.

 

https://www.lexjansen.com/search/searchresults.php?q=distance%20between%20locations

 

If you need straight line distances that gets a lot easier. You can use PROC GEOCODE to get the latitude/longitude and then use GEODIST() function to get the distance. You could probably do that to get an upper bound on your distances as a check anyways. 

 


@Suzy_Cat wrote:

Hello,

 

Can anyone share their experience in calculating distance between two nz addresses?

 

I had a quick browse and have no clue how to set up/access API.

 

Sad that SASHELP.ZIPCODE has no such info for New Zealand.

 

Would be great to get the practical idea on how to actually using SAS to calculate the distance/travel time required between two address vars.

 

Thanks

 


 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 876 views
  • 1 like
  • 2 in conversation