A data scientist builds an anomaly detection pipeline in SAS Viya. They want to flag observations whose Mahalanobis distance from the cluster center exceeds a threshold. Which SAS procedure or action set is most appropriate for computing Mahalanobis distances?
Select an answer to reveal the explanation.
Short Explanation
Use PROC IML to compute the Mahalanobis distance directly as (x-mu)' Sigma_inv (x-mu). That gives you the covariance-adjusted distance from the cluster center, which is what you need to flag outliers. The other choices don't provide that direct, covariance-based computation.
Full Explanation
The correct choice is PROC IML with matrix computation of (x-mu)' Sigma_inv (x-mu). Mahalanobis distance is a covariance-adjusted distance from a cluster center, so the computation needs the mean vector, the covariance matrix, and its inverse. PROC IML lets you form those matrices explicitly and evaluate the quadratic form for each observation, giving full control over the distance calculation and the thresholding logic. The approach using PROC DISTANCE with METHOD=MAHALANOBIS is wrong because PROC DISTANCE has no Mahalanobis method: its metrics (Euclidean, city-block, Gower and the rest) never use the inverse covariance matrix, so it cannot produce the covariance-adjusted distance from a cluster center that this scenario needs. The approach using PROC CORR with the COV option followed by a DATA step using a MAHALANOBIS= function is wrong because PROC CORR can produce a covariance matrix, but there is no MAHALANOBIS= function in a DATA step; you would still need matrix algebra to invert the covariance matrix and compute the quadratic form. The approach using PROC STANDARD with the STD= option to rescale each variable, followed by a Euclidean distance in PROC DISTANCE, is wrong because standardization only removes scale differences; it does not account for covariance or correlation among variables, so the resulting Euclidean distance is not a Mahalanobis distance.