Programming the statistical procedures from SAS

grouping locations

Reply
Contributor
Posts: 57

grouping locations

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?

Respected Advisor
Posts: 4,606

grouping locations

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
Grand Advisor
Posts: 16,908

grouping locations

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.

Respected Advisor
Posts: 4,606

grouping locations

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
Ask a Question
Discussion stats
  • 3 replies
  • 130 views
  • 0 likes
  • 3 in conversation