libname g350 "c:\sasdat\g350"; options linesize=130; *The simple illustration; ************************; data g350.simple(compress=yes); infile "c:\sasdat\g350\simple.csv" delimiter="," missover; length city $ 30; input city $ advert bank; run; proc cluster data=g350.simple method=single noeigen; id city; var advert bank; run; *The full cluster analysis; **************************; data g350.taylor(compress=yes); infile "c:\sasdat\g350\taylor.csv" delimiter="," missover; length city $ 30; input city $ KP CL EY AA PW GR DM LH SS TH OM DE YR TM PU AM HS BA NW ST CR DR MO PA CS BB BT UB AB CB BM WC LL CO SK BC DW GJ HH JD MC SQ WE AO CC FF total; run; proc princomp data=g350.taylor; var KP CL EY AA PW GR DM LH SS TH OM DE YR TM PU AM HS BA NW ST CR DR MO PA CS BB BT UB AB CB BM WC LL CO SK BC DW GJ HH JD MC SQ WE AO CC FF; run; proc print; run; %include "C:\SAS Server\V8\SAS\stat\sample\xmacro.sas"; %include "C:\SAS Server\V8\SAS\stat\sample\stdize.sas"; %include "C:\SAS Server\V8\SAS\stat\sample\distnew.sas"; %distance(data=g350.taylor,out=g350.gower,id=city,method=dgower, ord=KP CL EY AA PW GR DM LH SS TH OM DE YR TM PU AM HS BA NW ST CR DR MO PA CS BB BT UB AB CB BM WC LL CO SK BC DW GJ HH JD MC SQ WE AO CC FF); proc print data=g350.gower; run; proc mds data=g350.gower level=absolute pfinal out=g350.mdsout outres=g350.mdsres; id city; run; proc sort data=g350.mdsres; by descending residual; run; proc print data=g350.mdsres; where _ROW_="London" or _COL_="London"; run; title1 'Plot of Overall fit'; axis1 label=(angle=90 rotate=0) minor=none order=(0 to 1 by 0.1); axis2 minor=none order=(0 to 1 by 0.1); proc gplot data=res; plot fitdata*fitdist/vaxis=axis1 haxis=axis2; %plotit (data=g350.mdsout, datatype=mds, labelvar=city, vtoh=1.75, labfont=times); run; proc cluster data=g350.gower method=centroid outtree=tree psuedo rsquare; id city; var amsterdam--zurich; run; proc tree horizontal spaces=2 data=tree; id city; run; proc tree data=tree noprint n=18 out=out; id city; run; proc sort; by city; run; proc sort data=g350.taylor; by city; run; data clus1; merge g350.taylor out; by city; run; proc sort; by cluster; run; proc print; id city; by cluster; title "18 groups"; run; proc tree data=tree noprint n=11 out=out; id city; run; proc sort; by city; run; proc sort data=g350.taylor; by city; run; data clus1; merge g350.taylor out; by city; run; proc sort; by cluster; run; proc print; id city; by cluster; title "11 groups"; run; proc tree data=tree noprint n=4 out=out; id city; run; proc sort; by city; run; proc sort data=g350.taylor; by city; run; data clus1; merge g350.taylor out; by city; run; proc sort; by cluster; run; proc print; id city; by cluster; title "4 groups"; run;