BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9

Hello,

I have to find a way to calculate the actual driving distance not overhead distance but street driving.  I'm not sure what the best way to approach this would be.

I did see there is a function called Geodist but I'm not sure if that returns the overhead distance or street driving distance.

I'm using sas 9.4 TS1M2.

Thank you for any help you can give me.

7 REPLIES 7
Darrell_sas
SAS Employee

GEODIST calculates the straight line distance.  We do not have anything in SAS that calculates the driving distance.

There are some people who have calculated the driving distance using Google Maps, but this is illegal according to Google.

https://developers.google.com/maps/terms?hl=en  (See 10.1.1.H)

jerry898969
Pyrite | Level 9

Thank you Darrell.

I have been unable to find anything that I could use just with SAS.  I don't want to use a 3rd party site or software due to the sensitivity of my data.

Someone suggested STATA has functions that calculate driving distance so I'm going to look into that.  I guess I could calculate it with STATA then bring it back to SAS for the rest of the work.

Thank you again,

Jerry

gergely_batho
SAS Employee

To calculate street distances, you will need a graph that describes the length and connections of the streets.

If you have that, you can use shortest path algoritms to find the distance between 2 points or between set of points.

Shortest path algoritms are available in SAS/OR and SAS/SNA.

Reeza
Super User

Can you post the reference for how Stata calculates driving distance?

jerry898969
Pyrite | Level 9

Hi Reeza,

If I'm able to figure it out I will definitely post it here.

Jerry

MikeZdeb
Rhodochrosite | Level 12

Hi.  The SAS code posted here once worked great, but Google has once again revised their mapping HTML so I'm still working on fixing it ...

Driving Distances and Drive Times using SAS and Google Maps - sasCommunity

At the bottom of the web page, there's a link to a paper by Ash Roy and Yingbo Na from the Canadian Institute for Health Information in Torontoi ...

Batch Production of Driving Distances and Times Using SAS® and Web Map APIs

http://support.sas.com/resources/papers/proceedings12/091-2012.pdf

There's really no reason to bother with a lot of complicated programming since driving time/distance has all been worked out by Google, Mapquest. etc. and I think it would be a lot easier to write SAS code that uses the an API rather than rebuilding the wheel.

ps  There's a paper that used the SAS code on the SAS Community site that showed that in many cases, straight line distance (as in the GEODIST function) might suffice ... A Nationwide Comparison of Driving Distance Versus Straight-Line Distance to Hospitals

http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3835347/

Reeza
Super User

I think it's more of an issue that we're usually not allowed to send addresses to the API - especially in health care as it identifies our patients Smiley Sad

I've heard of people grabbing a yellow pages and using random address mixed with real addresses to help with the anonymize. An option we use as well is driving distances between zip codes - not as exact but close enough for many endeavors.

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!

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.

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
  • 7 replies
  • 1514 views
  • 6 likes
  • 5 in conversation