BookmarkSubscribeRSS Feed
aha123
Obsidian | Level 7

I have a list of stores and their location longitude and lattidue. If stores are with 30 miles of each other, they are assigned into the same group. I can write a data step to find out the grouping. I would like to know if I can use some SAS procedure to accomplish this task quickly. Can I use cluser analysis procedures for this?

3 REPLIES 3
PGStats
Opal | Level 21

You can, if you translate your lat/long data to UTM coordinates (say X, Y). I did this recently to group samples taken within 50 meters from each other, it looked like:

proc fastclus data=chloro summary radius=50 strict least=max

out=chloroClust outseed=seedClust cluster=Site clusterlabel="Site" noprint;

var x y;

id id;

run;

PG

PG
Reeza
Super User

Check out the geodist function in SAS as a starting point. 

How are specifying 'groups', do all stores have to be less than 30km from each other. Otherwise a store at one edge of the radius could be in another group theoretically...depends on your data of course.

PGStats
Opal | Level 21

I guess a cheap way of doing it using the geoDist function suggested by Reeza would be :

data haveXY(drop=refLong refLat);

retain refLong refLat;

set have;

if _n_ = 1 then do;

refLong = long;

refLat = lat;

end;

id = _n_;

x = geodist(lat,refLong,lat,long,"DM");

y = geodist(refLat,long,lat,long,"DM");

run;

proc fastclus data=haveXY summary radius=15 strict least=max

out=wantClust outseed=seedWant cluster=Site clusterlabel="Site" noprint;

var x y;

id id;

run;

The first store coordinates are arbitrarly chosen as a reference. The "DM" option means that your coordinates are in degrees and that the distance is returned in miles.

PG

PG

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1454 views
  • 0 likes
  • 3 in conversation