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?
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
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.
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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.