/* File "hatco3group.sas": three group illustrative example from book p296-314. Note comments in SAS are enclosed by "slash-star" and "star-slash." First import the hatco.xls data as usual. Skip the stepwise part (Tables 5.14-5.17), and aim straight for the results in Tables 5.18-5.20: highlight the following code (from "proc discrim" to the first "run;"), and select Run > Submit from the main menu. */ proc discrim canonical distance data=work.hatco testdata=work.hatco out=work.results list crossvalidate; class x14; var x1 x2 x3; freq analysis; testfreq holdout; priors proportional; run; /* In particular, you should be able to locate the following output: - eigenvalues = 1.935, 0.532 - canonical correlations = 0.812, 0.589 - Wilk's lambdas (called "likelihood ratio") = 0.222, 0.653 - standardized canonical coefficients (labeled "pooled within-class") - unstandardized canonical coefficients (labeled "raw") - function loadings (labeled "pooled within canonical structure") - linear discriminant (classification) function coefficients - group (class) means on canonical variables (centroids) - classification matrices for analysis (calibration) and holdout (test) samples, as well as cross-validation of the analysis sample - classification results for individuals in analysis sample Note the following differences between SAS and the book: - an F-test is used for Wilk's lambda rather than a chi-squared test - SAS does not compute the discriminant function loadings in Table 5.18 for variables not used in the analysis; it is not too difficult to compute loadings for variables not used in the analysis by exporting the results file to Excel and calculating loading = pooled correlation between a variable and a canonical discriminant function - see "loadings3.xls" for exact details - SAS does not produce "rotated values" (only unrotated ones); it is possible, but difficult, to produce rotated values (if you are interested, use SAS Help, click on Contents > Sample SAS Programs and Applications > SAS/STAT, then scroll down the list to find "Rotation of Canonical Variables" listed under the CANCORR procedure) Next, to profile correctly classified and misclassified observations run the following code to produce results for x14=1 in Table 5.21. */ data work.results; set work.results; x14_1=(x14=1); x14_2=(x14=2); x14_3=(x14=3); into_1=(_into_=1); into_2=(_into_=2); into_3=(_into_=3); proc ttest ci=none data=work.results; class into_1; var x1 x2 x3 x4 x5 x6 x7; freq x14_1; run; /* Run the following code to produce results for x14=2 in Table 5.21. */ proc ttest ci=none data=work.results; class into_2; var x1 x2 x3 x4 x5 x6 x7; freq x14_2; run; /* Run the following code to produce results for x14=3 in Table 5.21. */ proc ttest ci=none data=work.results; class into_3; var x1 x2 x3 x4 x5 x6 x7; freq x14_3; run; /* The following code will produce a plot similar to Figure 5.12. */ proc plot data=work.results; plot can2*can1=x14; run;