KCLUS Procedure
Example 16.2 Finding the Number of Clusters
(View the complete code for this example.)
This example uses the same data table that is loaded into your CAS session in Example 16.1.
You can find the number of clusters in the data table by specifying NOC=ABC in the PROC KCLUS statement as follows:
data mylib.iris;
set sashelp.iris;
run;
proc kclus data=mylib.iris maxclusters=9 seed=1234
NOC=ABC(B=10 minclusters=2 align=PCA criterion=FIRSTPEAK);
input SepalLength SepalWidth PetalLength PetalWidth;
ods output ABCStats=ABCStats1;
run;
PROC KCLUS generates several ODS tables, some of which are shown in Output 16.2.1 through Output 16.2.4.
Output 16.2.1 shows the parameters that are used in the aligned box criterion (ABC) method.
Output 16.2.1: Aligned Box Criterion Parameters
| ABC Parameters | |||
|---|---|---|---|
| Minimum Cluster | Maximum Cluster | Reference Distribution Count | Alignment Method |
| 2 | 9 | 10 | PCA |
Output 16.2.2 shows the statistics that are obtained for each candidate number of clusters.
Output 16.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.6313 | 10.1237 | 0.4923 | 0.0531 | 0.4392 |
| 3 | 8.9727 | 9.4894 | 0.5167 | 0.3678 | 0.1489 |
| 4 | 8.6811 | 8.9211 | 0.2400 | 0.0408 | 0.1992 |
| 5 | 8.5528 | 8.8012 | 0.2485 | 0.0536 | 0.1948 |
| 6 | 8.2784 | 8.4730 | 0.1945 | 0.0587 | 0.1359 |
| 7 | 8.2133 | 8.3702 | 0.1569 | 0.0517 | 0.1053 |
| 8 | 8.0750 | 8.5884 | 0.5134 | 0.0419 | 0.4715 |
| 9 | 8.0444 | 8.1240 | 0.0796 | 0.0639 | 0.0158 |
Output 16.2.3: Estimated Number of Clusters
| Estimated Number of Clusters | |
|---|---|
| Criterion | Number of Clusters |
| FirstPeak | 3 |
Output 16.2.4: Cluster Summary Table for Each Cluster
| Cluster Summary for Interval Variables | ||||||||
|---|---|---|---|---|---|---|---|---|
| Cluster | Frequency | Distance from Cluster Centroid to Observation | SSE | Standard Deviation | Nearest Cluster | Distance to Nearest Cluster Centroid | ||
| Minimum | Maximum | Average | ||||||
| 1 | 62 | 2.1994 | 16.6064 | 7.3815 | 3982.1 | 8.0142 | 2 | 17.9718 |
| 2 | 38 | 2.5958 | 15.2971 | 7.1984 | 2387.9 | 7.9272 | 1 | 17.9718 |
| 3 | 50 | 0.6618 | 12.4803 | 4.8171 | 1515.1 | 5.5047 | 1 | 33.5693 |
When you use the NOC= option, the KCLUS procedure first estimates the number of clusters, k, and then it displays the cluster analysis results for each of the k clusters as shown in Output 16.2.4.