Previous Page | Next Page

Language Reference

COV Function

COV( x <, excludemiss> ) ;

The COV function computes a sample variance-covariance matrix for data. The arguments are as follows:

x

specifies an numerical matrix of data. The COV function computes a variance-covariance matrix of the data.

excludemiss

specifies how missing values are handled. The following are valid options:

"listwise"

specifies that observations with missing values are excluded from the analysis. This is the default value.

"pairwise"

specifies that all nonmissing pairs of values for each pair of variables are included in the statistical computations.

The excludemiss argument is not case-sensitive. The first four characters are used to determine the value. For example, "LIST" and "listwise" specify the same option.

The COV function computes a sample variance-covariance matrix for data, as the following example shows:

x = {5 1 10,
     6 2 3,
     6 8 5,
     6 7 9,
     7 2 13};
cov = cov(x);
print cov;

Figure 23.67 Variance-Covariance Matrix
cov
0.5 0.25 0.75
0.25 10.5 -3.75
0.75 -3.75 16

The COV function handles missing values in the same way as the CORR procedure. For additional details, see the documentation for the CORR procedure (especially the NOMISS option) in the Base SAS Procedures Guide: Statistical Procedures.

It might be useful to use the ROWNAME= and COLNAME= options in the MATTRIB statement or the PRINT statement to associate names of variables to rows and columns of the correlation matrix, as shown in the example for the CORR function.

Previous Page | Next Page | Top of Page