The DISTANCE Procedure

Example 37.2 Financial Data – Stock Dividends

(View the complete code for this example.)

The following data set contains the average dividend yields for 15 utility stocks in the United States. The observations are names of the companies, and the variables correspond to the annual dividend yields for the period 1986–1990. The objective is to group similar stocks into clusters.

Before the cluster analysis is performed, the correlation similarity is chosen for measuring the closeness between each observation. Since distance type of measures are required by PROC CLUSTER, METHOD=DCORR is used in the PROC DISTANCE statement to transform the correlation measures to the distance measures. Notice that in Output 37.2.1, all the values in the distance matrix are between 0 and 2.

PROC CLUSTER performs hierarchical clustering by using agglomerative methods based on the distance data created from the previous PROC DISTANCE statement. Since the cubic clustering criterion is not suitable for distance data, only the pseudo F statistic is requested to identify the number of clusters.

The two clustering methods are Ward’s and the average linkage methods. Since the results of the pseudo statistic from both Ward’s and the average linkage methods contain many missing values, only the plot of the pseudo F statistic versus the number of clusters is requested along with the dendrogram by specifying PLOTS(ONLY)=(PSF DENDROGRAM) in the PROC CLUSTER statement.

Both Output 37.2.2 and Output 37.2.3 suggest four clusters. Both methods produce the same clustering result, as shown in Output 37.2.4 and Output 37.2.5. The four clusters are as follows:

  • Cincinnati G&E and Detroit Edison

  • Texas Utilities and Pennsylvania Power & Light

  • Union Electric, Iowa-Ill Gas & Electric, Oklahoma Gas & Electric, and Wisconsin Energy

  • Orange & Rockland Utilities, Kentucky Utilities, Kansas Power & Light, Allegheny Power, Green Mountain Power, Dominion Resources, and Minnesota Power & Light

title 'Stock Dividends';

data stock;
   length Company $ 27;
   input Company &$  Div_1986 Div_1987 Div_1988 Div_1989 Div_1990;
   datalines;
Cincinnati G&E               8.4    8.2    8.4    8.1    8.0
Texas Utilities              7.9    8.9   10.4    8.9    8.3
Detroit Edison               9.7   10.7   11.4    7.8    6.5
Orange & Rockland Utilities  6.5    7.2    7.3    7.7    7.9
Kentucky Utilities           6.5    6.9    7.0    7.2    7.5
Kansas Power & Light         5.9    6.4    6.9    7.4    8.0
Union Electric               7.1    7.5    8.4    7.8    7.7
Dominion Resources           6.7    6.9    7.0    7.0    7.4
Allegheny Power              6.7    7.3    7.8    7.9    8.3
Minnesota Power & Light      5.6    6.1    7.2    7.0    7.5
Iowa-Ill Gas & Electric      7.1    7.5    8.5    7.8    8.0
Pennsylvania Power & Light   7.2    7.6    7.7    7.4    7.1
Oklahoma Gas & Electric      6.1    6.7    7.4    6.7    6.8
Wisconsin Energy             5.1    5.7    6.0    5.7    5.9
Green Mountain Power         7.1    7.4    7.8    7.8    8.3
;
proc distance data=stock method=dcorr out=distdcorr;
   var interval(div_1986 div_1987 div_1988 div_1989 div_1990);
   id company;
run;
proc print data=distdcorr;
   id company;
   title2 'Distance Matrix for 15 Utility Stocks';
run;
title2;
ods graphics on;

/* compute pseudo statistic versus number of clusters and create plot */
proc cluster data=distdcorr method=ward pseudo plots(only)=(psf dendrogram);
   id company;
run;
/* compute pseudo statistic versus number of clusters and create plot */
proc cluster data=distdcorr method=average pseudo plots(only)=(psf dendrogram);
   id company;
run;

ods graphics off;

Output 37.2.1: Distance Matrix Based on the DCORR Coefficient

Stock Dividends
Distance Matrix for 15 Utility Stocks

CompanyCincinnati_G_ETexas_UtilitiesDetroit_EdisonOrange___Rockland_UtilitiesKentucky_UtilitiesKansas_Power___LightUnion_ElectricDominion_ResourcesAllegheny_PowerMinnesota_Power___LightIowa_Ill_Gas___ElectricPennsylvania_Power___LightOklahoma_Gas___ElectricWisconsin_EnergyGreen_Mountain_Power
Cincinnati G&E0.00000..............
Texas Utilities0.820560.00000.............
Detroit Edison0.405110.654530.00000............
Orange & Rockland Utilities1.353800.885831.273060.00000...........
Kentucky Utilities1.355810.925391.293820.122680.00000..........
Kansas Power & Light1.342270.943711.316960.199050.128740.00000.........
Union Electric0.985160.290430.890480.687980.718240.720820.00000........
Dominion Resources1.329450.968531.290160.332900.215100.241890.765870.00000.......
Allegheny Power1.304920.816661.245650.178440.157590.170290.584520.278190.00000......
Minnesota Power & Light1.240690.740821.204320.325810.304620.272310.483720.357330.156150.00000.....
Iowa-Ill Gas & Electric1.049240.431000.976160.611660.617600.617360.169230.635450.479000.363680.00000....
Pennsylvania Power & Light0.749310.378210.442561.035661.088781.128760.632851.143541.023580.993840.755960.00000...
Oklahoma Gas & Electric1.006040.301410.862000.680210.702590.731580.171220.729770.583910.507440.196730.602160.00000..
Wisconsin Energy1.179880.548301.030810.450130.471840.533810.374050.519690.375220.363190.302590.760850.280700.00000.
Green Mountain Power1.303970.880631.271760.269480.179090.153770.648690.173600.139580.193700.520831.092690.641750.448140


Output 37.2.2: Pseudo F versus Number of Clusters When METHOD=WARD

Pseudo  versus Number of Clusters When METHOD=WARD


Output 37.2.3: Pseudo F versus Number of Clusters When METHOD=AVERAGE

Pseudo  versus Number of Clusters When METHOD=AVERAGE


Output 37.2.4: Dendrogram of Semipartial R-Square Values When METHOD=WARD

Dendrogram of Semipartial R-Square Values When METHOD=WARD


Output 37.2.5: Dendrogram of Average Distance between Clusters When METHOD=AVERAGE

Dendrogram of Average Distance between Clusters When METHOD=AVERAGE