The DISTANCE Procedure |
PROC DISTANCE Statement |
The options available with the PROC DISTANCE statement are summarized in Table 32.1 and discussed in the following section.
Option |
Description |
---|---|
Standardize variables |
|
specifies the constant to add to each value after standardizing and multiplying by the value specified in the MULT= option |
|
specifies the relative fuzz factor for writing the output |
|
specifies the method for computing initial estimates for the A-estimates |
|
specifies the constant to multiply each value by after standardizing |
|
normalizes the scale estimator to be consistent for the standard deviation of a normal distribution |
|
suppresses standardization |
|
normalizes the scale estimator to have an expectation of approximately 1 for a standard normal distribution |
|
standardizes variables only (suppresses computation of the distance matrix) |
|
specifies the variances divisor |
|
Generate distance matrix |
|
specifies the value to be used as an absence value for all the asymmetric nominal variables |
|
specifies the method for computing proximity measures |
|
specifies a prefix for naming the distance variables in the OUT= data set |
|
specifies the method of assigning scores to ordinal variables |
|
specifies the shape of the proximity matrix to be stored in the OUT= data set |
|
specifies the numeric constant used to replace undefined distances |
|
Replace missing values |
|
omits observations with missing values from computation of the location and scale measures, if standardization applies; outputs missing values to the distance matrix for observations with missing values |
|
replaces missing data with zero in the standardized data |
|
replaces missing data with the location measure (does not standardize the data) |
|
Specify data set details |
|
specifies the input data set |
|
specifies the output data set |
|
specifies the output data set for standardized scores |
These options and their abbreviations are described (in alphabetical order) in the remainder of this section.
specifies the value to be used as an absence value in an irrelevant absent-absent match for all of the asymmetric nominal variables. If you want to specify a different absence value for a particular variable, use the ABSENT= option in the VAR statement. See the ABSENT= option in the section VAR Statement for details.
An absence value for a variable can be either a numeric value or a quoted string consisting of combinations of characters. For instance, ., -999, and "NA" are legal values for the ABSENT= option.
The default absence value for a character variable is "NONE" (notice that a blank value is considered a missing value), and the default absence value for a numeric variable is 0.
specifies a constant, , to add to each value after standardizing and multiplying by the value you specify in the MULT= option. The default value is 0.
specifies the input data set containing observations from which the proximity is computed. If you omit the DATA= option, the most recently created SAS data set is used.
specifies the relative fuzz factor for computing the standardized scores. The default value is 1E–14. For the OUTSDZ= data set, the score is computed as follows:
where is the numeric constant specified in the MULT= option, or 1 if MULT= option is not specified.
specifies the method of computing initial estimates for the A-estimates (ABW, AWAVE, and AHUBER). The following methods are not allowed for the INITIAL= option: ABW, AHUBER, AWAVE, and IN.
The default value is INITIAL=MAD.
specifies the method of computing proximity measures.
For use in PROC CLUSTER, distance or dissimilarity measures such as METHOD=EUCLID or METHOD=DGOWER should be chosen.
The following six tables outline the proximity measures available for the METHOD= option. These tables are classified by levels of measurement accepted by each method. There are three to four columns in each table: the proximity measures (Method) column, the upper and lower bounds (Range) column(s), and the types of proximity (Type) column.
The Type column has two possible values: "sim" if a method generate similarity or "dis" if a method generates distance or dissimilarity measures.
For formulas and descriptions of these methods, see the section Details: DISTANCE Procedure.
Table 32.2 lists the range and output matrix type of the GOWER and DGOWER methods. These two methods accept all measurement levels including ratio, interval, ordinal, nominal, and asymmetric nominal. METHOD=GOWER or METHOD=DGOWER always implies standardization. Assuming all the numeric (ordinal, interval, and ratio) variables are standardized by their corresponding default methods, the possible range values for both methods in the second column of this table are on or between 0 and 1. To find out the default methods of standardization for METHOD=GOWER or METHOD=DGOWER, see the STD= option in the section VAR Statement. Entries in this table are as follows:
Gower and Legendre (1986) similarity
1 minus GOWER
Method |
Range |
Type |
---|---|---|
GOWER |
0 to 1 |
sim |
DGOWER |
0 to 1 |
dis |
Table 32.3 lists methods accepting ratio, interval, and ordinal variables. Entries in this table are as follows:
Euclidean distance
squared Euclidean distance
size distance
shape distance
covariance
correlation
correlation transformed to Euclidean distance
squared correlation
one minus squared correlation
Minkowski () distance, where is a positive numeric value
, city-block, or Manhattan distance
generalized Euclidean distance where is a positive numeric value and is a nonnegative numeric value. The distance between two observations is the th root of sum of the absolute differences to the th power between the values for the observations.
Method |
Range |
Type |
---|---|---|
EUCLID |
|
dis |
SQEUCLID |
|
dis |
SIZE |
|
dis |
SHAPE |
|
dis |
COV |
|
sim |
CORR |
–1 to 1 |
sim |
DCORR |
0 to 2 |
dis |
SQCORR |
0 to 1 |
sim |
DSQCORR |
0 to 1 |
dis |
L() |
|
dis |
CITYBLOCK |
|
dis |
CHEBYCHEV |
|
dis |
POWER() |
|
dis |
Table 32.4 lists methods accepting ratio variables. Notice that in the second column of this table, all of the possible range values are nonnegative, because ratio variables are assumed to be positive. Entries in this table are as follows:
similarity ratio (if variables are binary, this is the Jaccard coefficient)
one minus similarity ratio
Lance and Williams nonmetric coefficient
Canberra metric distance coefficient
cosine coefficient
dot (inner) product coefficient
overlap similarity
overlap dissimilarity
chi-squared coefficient
squared root of chi-squared coefficient
phi-squared coefficient
squared root of phi-squared coefficient
Method |
Range |
Type |
---|---|---|
SIMRATIO |
0 to 1 |
sim |
DISRATIO |
0 to 1 |
dis |
NONMETRIC |
0 to 1 |
dis |
CANBERRA |
0 to 1 |
dis |
COSINE |
0 to 1 |
sim |
DOT |
|
sim |
OVERLAP |
|
sim |
DOVERLAP |
|
dis |
CHISQ |
|
dis |
CHI |
|
dis |
PHISQ |
|
dis |
PHI |
|
dis |
Table 32.5 lists methods accepting nominal variables. Entries in this table are:
Hamming distance
simple matching coefficient
simple matching coefficient transformed to Euclidean distance
simple matching coefficient transformed to squared Euclidean distance
Hamann coefficient
Roger and Tanimoto
Sokal and Sneath 1
Sokal and Sneath 3
Method |
Range |
Type |
---|---|---|
HAMMING |
0 to |
dis |
MATCH |
0 to 1 |
sim |
DMATCH |
0 to 1 |
dis |
DSQMATCH |
0 to 1 |
dis |
HAMANN |
–1 to 1 |
sim |
RT |
0 to 1 |
sim |
SS1 |
0 to 1 |
sim |
SS3 |
0 to 1 |
sim |
Note that denotes the number of variables or dimensionality.
Table 32.6 lists methods that accept asymmetric nominal variables. Use the ABSENT= option to create a value to be considered absent. Entries in this table are as follows:
Dice coefficient or Czekanowski/Sorensen similarity coefficient
Russell and Rao
Binary Lance and Williams nonmetric, or Bray-Curtis coefficient
Kulcynski 1
Method |
Range |
Type |
---|---|---|
DICE |
0 to 1 |
sim |
RR |
0 to 1 |
sim |
BLWNM |
0 to 1 |
dis |
K1 |
|
sim |
Table 32.7 lists methods accepting asymmetric nominal and ratio variables. Use the ABSENT= option to create a value to be considered absent. There are four instead of three columns in this table. The second column contains possible range values if only one level of measurement (either ratio or asymmetric nominal but not both) is specified; the third column contains possible range values if both levels are specified.
The JACCARD method is equivalent to the SIMRATIO method if there is no asymmetric nominal variable; if both ratio and asymmetric nominal variables are present, the coefficient is computed as the sum of the coefficient from the ratio variables and the coefficient from the asymmetric nominal variables. See "Proximity Measures" in the section Details: DISTANCE Procedure for the formula and descriptions of the JACCARD method. Entries in this table are as follows:
Jaccard similarity coefficient
Jaccard dissimilarity coefficient
Method |
Range (one level) |
Range (two levels) |
Type |
---|---|---|---|
JACCARD |
0 to 1 |
0 to 2 |
sim |
DJACCARD |
0 to 1 |
0 to 2 |
dis |
specifies a numeric constant, , by which to multiply each value after standardizing. The default value is 1.
omits observations with missing values from computation of the location and scale measures when standardizing; generates undefined (missing) distances for observations with missing values when computing distances. Use the UNDEF= option to specify the undefined values.
If a distance matrix is created to be used as an input to PROC CLUSTER, the NOMISS option should not be used because the CLUSTER procedure does not accept distance matrices with missing values.
normalizes the scale estimator to be consistent for the standard deviation of a normal distribution when you specify the option STD=AGK, STD=IQR, STD=MAD, or STD=SPACING in the VAR statement.
suppresses standardization of the variables. The NOSTD option should not be specified with the STDONLY option or with the REPLACE option.
specifies the name of the SAS data set created by PROC DISTANCE. The output data set contains the BY variables, the ID variable, computed distance variables, the COPY variables, the FREQ variable, and the WEIGHT variables.
If you omit the OUT= option, PROC DISTANCE creates an output data set named according to the DATA convention.
specifies the name of the SAS data set containing the standardized scores. The output data set contains a copy of the DATA= data set, except that the analyzed variables have been standardized. Analyzed variables are those listed in the VAR statement.
specifies a prefix for naming the distance variables in the OUT= data set. By default, the names are Dist1, Dist2, ..., Dist. If you specify PREFIX=ABC, the variables are named ABC1, ABC2, ..., ABCn. If the ID statement is also specified, the variables are named by appending the value of the ID variable to the prefix.
specifies the method of assigning scores to ordinal variables. The available methods are listed as follows:
assigns consecutive integers to each category with consideration of the frequency value. This is the default method.
assigns consecutive integers to each category regardless of frequencies.
The following example explains how each method assigns the rank scores. Suppose the data contain an ordinal variable ABC with values A, B, C. There are two ways to assign numbers. One is to use midranks, which depend on the frequencies of each category. Another is to assign consecutive integers to each category, regardless of frequencies.
ABC |
MIDRANK |
INDEX |
A |
1.5 |
1 |
A |
1.5 |
1 |
B |
4 |
2 |
B |
4 |
2 |
B |
4 |
2 |
C |
6 |
3 |
replaces missing data with zero in the standardized data (to correspond to the location measure before standardizing). To replace missing data with something else, use the MISSING= option in the VAR statement. The REPLACE option implies standardization.
You cannot specify the following options together:
both the REPLACE and the REPONLY options
both the REPLACE and the NOSTD options
replaces missing data with the location measure specified by the MISSING= option or the STD= option (if the MISSING= option is not specified), but does not standardize the data. If the MISSING= option is not specified and METHOD=GOWER is specified, missing values are replaced by the location measure from the RANGE method (the minimum value), no matter what the value of the STD= option is.
You cannot specify both the REPLACE and the REPONLY options.
specifies the shape of the proximity matrix to be stored in the OUT= data set. SHAPE=TRIANGLE requests the matrix to be stored as a lower triangular matrix; SHAPE=SQUARE requests that the matrix be stored as a squared matrix. Use SHAPE=SQUARE if the output data set is to be used as input to the MODECLUS procedures. The default is TRIANGLE.
normalizes the scale estimator to have an expectation of approximately 1 for a standard normal distribution when the STD=SPACING option is specified.
standardizes variables only and computes no distance matrix. You must use the OUTSDZ= option to save the standardized scores. You cannot specify both the STDONLY option and the NOSTD option.
specifies the numeric constant used to replace undefined distances, such as when an observation has all missing values, or if a divisor is zero.
specifies the divisor to be used in the calculation of distance, dissimilarity, or similarity measures, and for standardizing variables whenever a variance or covariance is computed. By default, VARDEF=DF. The values and associated divisors are as follows:
Value |
Divisor |
Formula |
---|---|---|
DF |
degrees of freedom |
|
N |
number of observations |
|
WDF |
sum of weights minus 1 |
( |
WEIGHT | WGT |
sum of weights |
|
Copyright © SAS Institute, Inc. All Rights Reserved.