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

The KCLUS Procedure

ABC Parameters
Minimum
Cluster
Maximum
Cluster
Reference
Distribution
Count
Alignment
Method
2910PCA


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
GapSimulation
Adjusted
Standard
Deviation
One
Standard
Error
Adjusted
Gap
InputReference
29.631310.12370.49230.05310.4392
38.97279.48940.51670.36780.1489
48.68118.92110.24000.04080.1992
58.55288.80120.24850.05360.1948
68.27848.47300.19450.05870.1359
78.21338.37020.15690.05170.1053
88.07508.58840.51340.04190.4715
98.04448.12400.07960.06390.0158


Output 16.2.3: Estimated Number of Clusters

Estimated Number of Clusters
CriterionNumber of
Clusters
FirstPeak3


Output 16.2.4: Cluster Summary Table for Each Cluster

Cluster Summary for Interval Variables
ClusterFrequencyDistance from Cluster Centroid
to Observation
SSEStandard
Deviation
Nearest
Cluster
Distance
to
Nearest
Cluster
Centroid
MinimumMaximumAverage
1622.199416.60647.38153982.18.0142217.9718
2382.595815.29717.19842387.97.9272117.9718
3500.661812.48034.81711515.15.5047133.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.

Last updated: June 22, 2026