SAS Code For Discriminant Analysis For Two Groups

Multivariate Statistics: SAS program code for Discriminant Analysis for Two Groups. SAS software has a procedure “PROC DISCRIM” for performing Discriminant Analysis. The procedure can create a linear discriminant function for a given dataset. The linear discriminant function can be used to classify new observations to one of the two available populations.

Discriminant analysis is sometimes know as classification analysis. It can be used to build rules that can classify new observations into two or more labeled classes. The emphasis is on deriving a rule that can be used to optimally assign new observations to the labeled classes.

Suppose there are two populations, each of them has p variables and follows a multivariate normal distribution. Suppose a new observation vector is known to come from either population 1 or population 2. A rule is needed that can be used to predict from which of the two populations the new observation vector is most likely to have come. The most commonly used discriminant rule for two populations is the linear discriminant function rule.

Run the sample SAS program for Discriminant Analysis below:
****

dm log ‘clear’;
dm output ‘clear’;
options nodate;
data Twogroups;
input Groups X1 X2 X3 X4 X5 X6 @@;
datalines;
1 242.0 23.2 25.4 30.0 38.4 13.4
1 290.0 24.0 26.3 31.2 40.0 13.8
1 340.0 23.9 26.5 31.1 39.8 15.1
1 363.0 26.3 29.0 33.5 38.0 13.3
1 500.0 26.8 29.7 34.5 41.1 15.3
1 390.0 27.6 30.0 35.0 36.2 13.4
1 98.0 17.5 18.8 21.2 26.3 13.7
1 340.0 23.9 26.5 31.1 39.8 15.1
1 450.0 27.6 30.0 35.1 39.9 13.8
1 500.0 28.5 30.7 36.2 39.3 13.7
1 475.0 28.4 31.0 36.2 39.4 14.1
1 500.0 28.7 31.0 36.2 39.7 13.3
2 40.0 12.9 14.1 16.2 25.6 14.0
2 69.0 16.5 18.2 20.3 26.1 13.9
2 78.0 17.5 18.8 21.2 26.3 13.7
2 187.0 18.2 19.8 22.2 25.3 14.3
2 150.0 20.4 22.0 24.7 23.5 15.2
2 145.0 20.5 22.0 24.3 27.3 14.6
2 160.0 20.5 22.5 25.3 27.8 15.1
2 140.0 21.0 22.5 25.0 26.2 13.3
2 160.0 21.1 22.5 25.0 25.6 15.2
2 169.0 22.0 24.0 27.2 27.7 14.1
;
proc discrim data=Twogroups list crosslist;
class Groups;
title ‘Discriminant Analysis for Two Groups’;
run;
quit;

****
Leave me a comment if you have questions.

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × four =

This site uses Akismet to reduce spam. Learn how your comment data is processed.