Fluorite | Level 6

## geodist and cross join help

Hello,

I have a data set with 500k members (by memid) and lat and lon in degrees, and a data set with 300 providers (by prov) with lat and lon in degrees.  Both are geocoded at the street address level.

data member_geo; set work.geocoded_mems (rename=(X=LA1 y=LO1)); run;

data prov_geo; set work.geocoded_provs (rename=(X=LA2 Y=LO2)); run;

I want to calculate distances between member to providers using geodist.

geodist(LA1,LO1,LA2,LO2,'M')

Can someone help me find the appropriate cross join and distance calculation?

Thank you very much.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

5 REPLIES 5
Super User

## Re: geodist and cross join help

You say by zipcode, but then refer to lat/long? Which are you using?

It may be better, and more efficient, to do it at the zipcode level and then merge it back to the provider level.

If you want code, it helps if you post some sample data. You could use the zipcode table to generate random data.

Fluorite | Level 6

## Re: geodist and cross join help

Hello, sorry for being unclear.

I have geocoded members and providers at the street address level.

I would like to calculate the distances from patients to providers in miles.

Super User

## Re: geodist and cross join help

Fluorite | Level 6

## Re: geodist and cross join help

Thank you for the example Reza.

data member_geo; set work.geocoded_mems (rename=(X=LA1 Y=LO1)); run;

data prov_geo; set work.geocoded_provs (rename=(X=LA2 Y=LO2)); run;

proc sql;
create table geo_join as
select a.LA1, a.LO1, a.memid, a.zip, b.LA2, b.LO2, b.prov,
geodist(a.LA1, a.LO1, b.LA2, b.LO2,'m') as geodist
from member_geo a, prov_geo b;
quit;

This is my code, but i am getting null values for geodist.

Any idea why? I have lat and lon in degrees in both sets.

Super User

## Re: geodist and cross join help

Without a log or any sample data I can't say...
Discussion stats
• 5 replies
• 1100 views
• 2 likes
• 2 in conversation