* -------------------------------------------------------------------- File: cluster.crime Purpose: cluster analysis of the crime data set * -------------------------------------------------------------------; OPTIONS NODATE NOCENTER PAGENO=1 LINESIZE=120; * - NOTE: You must assign the LIBNAME p7291 to the directory/folder containing the data set crime; *LIBNAME p7291 ''; DATA temp; SET p7291.crime; RUN; TITLE Cluster Analysis of the Crime data set; TITLE2 'Average Linkage Method'; PROC CLUSTER DATA=temp METHOD=average STD PSEUDO RSQUARE OUTTREE=treedata; VAR murder--auto; ID state; RUN; *- the TREE procedure produces a dendrogram; PROC TREE DATA=treedata HORIZONTAL; ID state; RUN; * - You should try different methods (see the sas documentation for the METHOD option for PROC CLUSTER) and compare the results with one another; TITLE2 'Nearest Neighbor Density'; PROC CLUSTER DATA=temp METHOD=DENSITY K=3 STD OUTTREE=treedata; VAR murder--auto; ID state; RUN; *- the TREE procedure produces a dendrogram; PROC TREE DATA=treedata HORIZONTAL; ID state; RUN;