The CLUSTER Procedure

Example 34.1 Cluster Analysis of Flying Mileages between 10 American Cities

(View the complete code for this example.)

This example clusters 10 American cities based on the flying mileages between them. Six clustering methods are shown with corresponding dendrograms. The EML method cannot be used because it requires coordinate data. The other omitted methods produce the same clusters, although not the same distances between clusters, as one of the illustrated methods: complete linkage and the flexible-beta method yield the same clusters as Ward’s method, McQuitty’s similarity analysis produces the same clusters as average linkage, and the median method corresponds to the centroid method.

All of the methods suggest a division of the cities into two clusters along the east-west dimension. There is disagreement, however, about which cluster Denver should belong to. Some of the methods indicate a possible third cluster that contains Denver and Houston.

The following step displays the city mileage SAS data set, which is available in the Sashelp library and is designated as a TYPE=DISTANCE data set when it is used by PROC CLUSTER:

proc print noobs data=sashelp.mileages;
run;

Output 34.1.1: City Mileage Data Set

AtlantaChicagoDenverHoustonLosAngelesMiamiNewYorkSanFranciscoSeattleWashingtonDCCity
0.........Atlanta
5870........Chicago
12129200.......Denver
7019408790......Houston
1936174583113740.....Los Angeles
6041188172696823390....Miami
74871316311420245110920...New York
213918589491645347259425710..San Francisco
2182173710211891959273424086780.Seattle
543597149412202300923205244223290Washington D.C.


A partial listing from the following statements include Output 34.1.2 and Output 34.1.3:

title 'Cluster Analysis of Flying Mileages Between 10 American Cities';
ods graphics on;

title2 'Using METHOD=AVERAGE';
proc cluster data=sashelp.mileages(type=distance) method=average pseudo;
   id City;
run;

Output 34.1.2: Cluster History Using METHOD=AVERAGE

Cluster Analysis of Flying Mileages Between 10 American Cities
Using METHOD=AVERAGE

The CLUSTER Procedure
Average Linkage Cluster Analysis

Cluster History
Number
of
Clusters
Clusters JoinedFreqPseudo F
Statistic
Pseudo
t-Squared
Norm RMS
Distance
Tie
9New YorkWashington D.C.266.7.0.1297 
8Los AngelesSan Francisco239.2.0.2196 
7AtlantaChicago221.7.0.3715 
6CL7CL9414.53.40.4149 
5CL8Seattle312.47.30.5255 
4DenverHouston213.9.0.5562 
3CL6Miami515.53.80.6185 
2CL3CL4716.05.30.8005 
1CL2CL510.16.01.2967 


Output 34.1.3: Dendrogram Using METHOD=AVERAGE

Dendrogram Using METHOD=AVERAGE


A partial listing from the following statements include Output 34.1.4 and Output 34.1.5:

title2 'Using METHOD=CENTROID';
proc cluster data=sashelp.mileages(type=distance) method=centroid pseudo;
   id City;
run;

Output 34.1.4: Cluster History Using METHOD=CENTROID

Cluster Analysis of Flying Mileages Between 10 American Cities
Using METHOD=CENTROID

The CLUSTER Procedure
Centroid Hierarchical Cluster Analysis

Cluster History
Number
of
Clusters
Clusters JoinedFreqPseudo F
Statistic
Pseudo
t-Squared
Norm
Centroid
Distance
Tie
9New YorkWashington D.C.266.7.0.1297 
8Los AngelesSan Francisco239.2.0.2196 
7AtlantaChicago221.7.0.3715 
6CL7CL9414.53.40.3652 
5CL8Seattle312.47.30.5139 
4DenverCL5412.42.10.5337 
3CL6Miami514.23.80.5743 
2CL3Houston622.12.60.6091 
1CL2CL410.22.11.173 


Output 34.1.5: Dendrogram Using METHOD=CENTROID

Dendrogram Using METHOD=CENTROID


A partial listing from the following statements include Output 34.1.6 and Output 34.1.7:

title2 'Using METHOD=DENSITY K=3';
proc cluster data=sashelp.mileages(type=distance) method=density k=3;
   id City;
run;

Output 34.1.6: Cluster History Using METHOD=DENSITY K=3

Cluster Analysis of Flying Mileages Between 10 American Cities
Using METHOD=DENSITY K=3

The CLUSTER Procedure
Density Linkage Cluster Analysis

Cluster History
Number
of
Clusters
 FreqNormalized
Fusion Density
 Maximum Density
in Each Cluster
Tie
Clusters JoinedLesserGreater
9AtlantaWashington D.C.296.106 92.5043100.0 
8CL9Chicago395.263 90.9548100.0 
7CL8New York486.465 76.1571100.0 
6CL7Miami574.079 58.8299100.0T
5CL6Houston674.079 61.7747100.0 
4Los AngelesSan Francisco271.968 65.343080.0885 
3CL4Seattle366.341 56.621580.0885 
2CL3Denver463.509 61.774780.0885 
1CL5CL21061.775*80.0885100.0 


Output 34.1.7: Dendrogram Using METHOD=DENSITY K=3

Dendrogram Using METHOD=DENSITY K=3


A partial listing from the following statements include Output 34.1.8 and Output 34.1.9:

title2 'Using METHOD=SINGLE';
proc cluster data=sashelp.mileages(type=distance) method=single;
   id City;
run;

Output 34.1.8: Cluster History Using METHOD=SINGLE

Cluster Analysis of Flying Mileages Between 10 American Cities
Using METHOD=SINGLE

The CLUSTER Procedure
Single Linkage Cluster Analysis

Cluster History
Number
of
Clusters
Clusters JoinedFreqNorm
Minimum
Distance
Tie
9New YorkWashington D.C.20.1447 
8Los AngelesSan Francisco20.2449 
7AtlantaCL930.3832 
6CL7Chicago40.4142 
5CL6Miami50.4262 
4CL8Seattle30.4784 
3CL5Houston60.4947 
2DenverCL440.5864 
1CL3CL2100.6203 


Output 34.1.9: Dendrogram Using METHOD=SINGLE

Dendrogram Using METHOD=SINGLE


A partial listing from the following statements include Output 34.1.10 and Output 34.1.11:

title2 'Using METHOD=TWOSTAGE K=3';
proc cluster data=sashelp.mileages(type=distance) method=twostage k=3;
   id City;
run;

Output 34.1.10: Cluster History Using METHOD=TWOSTAGE K=3

Cluster Analysis of Flying Mileages Between 10 American Cities
Using METHOD=TWOSTAGE K=3

The CLUSTER Procedure
Two-Stage Density Linkage Clustering

Cluster History
Number
of
Clusters
 FreqNormalized
Fusion Density
Maximum Density
in Each Cluster
Tie
Clusters JoinedLesserGreater
9AtlantaWashington D.C.296.10692.5043100.0 
8CL9Chicago395.26390.9548100.0 
7CL8New York486.46576.1571100.0 
6CL7Miami574.07958.8299100.0T
5CL6Houston674.07961.7747100.0 
4Los AngelesSan Francisco271.96865.343080.0885 
3CL4Seattle366.34156.621580.0885 
2CL3Denver463.50961.774780.0885 
1CL5CL21061.77580.0885100.0 


Output 34.1.11: Dendrogram Using METHOD=TWOSTAGE K=3

Dendrogram Using METHOD=TWOSTAGE K=3


A partial listing from the following statements include Output 34.1.12 and Output 34.1.13:

title2 'Using METHOD=WARD';
proc cluster data=sashelp.mileages(type=distance) method=ward pseudo;
   id City;
run;

Output 34.1.12: Cluster History Using METHOD=WARD

Cluster Analysis of Flying Mileages Between 10 American Cities
Using METHOD=WARD

The CLUSTER Procedure
Ward's Minimum Variance Cluster Analysis

Cluster History
Number
of
Clusters
Clusters JoinedFreqSemipartial
R-Square
R-SquarePseudo F
Statistic
Pseudo
t-Squared
Tie
9New YorkWashington D.C.20.0019.99866.7. 
8Los AngelesSan Francisco20.0054.99339.2. 
7AtlantaChicago20.0153.97721.7. 
6CL7CL940.0296.94814.53.4 
5DenverHouston20.0344.91313.2. 
4CL8Seattle30.0391.87413.97.3 
3CL6Miami50.0586.81615.53.8 
2CL3CL570.1488.66716.05.3 
1CL2CL4100.6669.000.16.0 


Output 34.1.13: Dendrogram Using METHOD=WARD

Dendrogram Using METHOD=WARD