proc sort data=sites out=sort;
by zip;
run;
data a;
set sashelp.zipcode;
keep zip x y;
run;
data b;
merge a(in=ina) sort(in=insort);
by zip;
if insort;
run;
proc sort data=b out=b1;
by population;
run;
data b2;
length site $30.;
x1=0;
y1=0;
site='0';
population1=0;
n=0;
set b1; if population>=20 then output;
else
do;
do while(population1<20);
set b1;
population1=(population1+population);
x1=sum(x1,x);
y1=sum(y1,y);
n=n+1;
end;
x1=x1/n;
y1=y1/n;
output;
end;
;
keep x1 y1 population1 zip;
run;
坐等被优化...如果值得优化的话..局限性如下: 不知道那几个site合并起来了; 首先按照pop排序的, 所以前面几个比较小pop的合并在了一起,


雷达卡




京公网安备 11010802022788号







