The HPCLUS Procedure
Example 5.2 Finding the Number of Clusters
You can find the number of clusters in the data set by specifying NOC=ABC in the PROC HPCLUS statement as follows:
proc hpclus data=sampsio.dmairis maxclusters=9
NOC=ABC(B=10 minclusters=2 align=PCA criterion=FIRSTPEAK);
input sep: pet: ;
ods output ABCStats=ABCStats1;
run;
These statements create three additional ODS tables, which are shown in Output 5.2.1, Output 5.2.2, and Output 5.2.4. Output 5.2.1 shows the parameters that are used in the aligned box criterion (ABC) method.
Output 5.2.1: Aligned Box Criterion Parameters
| Canonical Discriminant Analysis of Iris Clusters |
| Plot of Canonical Variables Identified by Cluster |
| ABC Parameters | |||
|---|---|---|---|
| Minimum Cluster | Maximum Cluster | Reference Distribution Count | Alignment Method |
| 2 | 9 | 10 | PCA |
Output 5.2.2 shows the statistics that are obtained for each candidate number of clusters.
Output 5.2.2: Aligned Box Criterion Statistics
| ABC Statistics | |||||
|---|---|---|---|---|---|
| Number of Clusters | Logarithm of Within-Cluster SSE | Gap | Simulation Adjusted Standard Deviation | One Standard Error Adjusted Gap | |
| Input | Reference | ||||
| 2 | 9.6315 | 10.0950 | 0.4635 | 0.0469 | 0.4167 |
| 3 | 8.9739 | 9.3249 | 0.3510 | 0.0513 | 0.2997 |
| 4 | 8.6565 | 8.9785 | 0.3220 | 0.0332 | 0.2889 |
| 5 | 8.5146 | 8.8086 | 0.2940 | 0.0500 | 0.2440 |
| 6 | 8.2676 | 8.6217 | 0.3541 | 0.0465 | 0.3076 |
| 7 | 8.1476 | 8.5464 | 0.3988 | 0.0494 | 0.3494 |
| 8 | 8.0911 | 8.4498 | 0.3587 | 0.0906 | 0.2681 |
| 9 | 8.0416 | 8.4225 | 0.3810 | 0.1055 | 0.2754 |
The following statements plot the gap values:
title "ABC Statistics Plot Using Gap Values";
proc sgplot data= ABCStats1;
xaxis type=discrete;
series x= K y= Gap;
run;
title ' ';
Output 5.2.3 shows that the first peak value is at 4. This result is also shown in the estimated number of clusters table, which is shown in Output 5.2.4.
Output 5.2.3: Gap Values

Output 5.2.4: Estimated Number of Clusters
| Estimated Number of Clusters | |
|---|---|
| Criterion | Number of Clusters |
| FIRSTPEAK | 7 |
When you use the NOC= option, the HPCLUS procedure first estimates the number of clusters, k, and then it displays the cluster analysis results with k. Output 5.2.5 shows the cluster summary table that is obtained by four clusters.
Output 5.2.5: Cluster Summary Table for Four Clusters
| Cluster Summary | ||||||||
|---|---|---|---|---|---|---|---|---|
| Cluster | Frequency | Distance from Cluster Centroid to Observation | SSE | Standard Deviation | Nearest Cluster | Distance to Nearest Cluster Centroid | ||
| Maximum | Minimum | Average | ||||||
| 1 | 28 | 10.6989 | 1.6155 | 5.3177 | 974.9 | 5.9008 | 7 | 11.9753 |
| 2 | 12 | 8.6530 | 3.5178 | 5.9555 | 465.5 | 6.2283 | 4 | 11.9158 |
| 3 | 15 | 6.5858 | 2.1229 | 3.7941 | 242.4 | 4.0200 | 7 | 7.1324 |
| 4 | 22 | 7.5029 | 2.5801 | 4.2624 | 431.5 | 4.4290 | 7 | 9.9613 |
| 5 | 27 | 8.6154 | 1.0377 | 3.7210 | 445.9 | 4.0640 | 6 | 7.8249 |
| 6 | 23 | 8.6385 | 1.3886 | 3.2684 | 317.7 | 3.7163 | 5 | 7.8249 |
| 7 | 23 | 8.1775 | 2.0960 | 4.7216 | 577.0 | 5.0085 | 3 | 7.1324 |