New Contributor
Posts: 2

# Compute Mahalanobis Distance from a reference point

I Have 8 variables, (x1-x8) and 310 observations for each variable, with no missing observations.

I Need to compute Mahalanobis Distance from a reference point of (7,7,7,7,7,7,7,7).

I understand that Proc IML is the easiest method for this.  Can someone assist me with the SAS code necessary to do this?

PROC Star
Posts: 8,165

SAS Super FREQ
Posts: 4,243

## Re: Compute Mahalanobis Distance from a reference point

SAS/IML 12.1 supports the MAHALANOBIS function.  If X is the data matrix, then do this:

center = {7 7 7 7 7 7 7 7};

md = mahalanobis(X, center);

New Contributor
Posts: 2

## Re: Compute Mahalanobis Distance from a reference point

Oh, that is intuitively obvious.  Thanks.  One more question:

the data matrix would simoly be defined as:

X={x1 x2 x3 x4 x5 x6 x7 x8};

SAS Super FREQ
Posts: 4,243

## Re: Compute Mahalanobis Distance from a reference point

That is the mathematical notation. The corresponding IML syntax would be

X = x1 || x2 || x3 || x4 ||x5 ||x6 || x7 || x8;

or alternatively:

varNames = "x1":"x8";

use MyData;