Sie sind auf Seite 1von 2

/* -------------------------------------------------* * File: candisc.wolves.

sas * * Example of a Canonical Discriminant Analysis using * the wolves data * * ---------------------------------------------------- */ OPTIONS NOCENTER PAGENO=1 NODATE; /* The first task is to create a variable and a format for each group so that we can plot the results of the canonical analysis. First we will establish the print formats for the groups */ PROC FORMAT; VALUE wolffmt 1='RM Female' 2='RM Male' 3='AR Female' 4='AR Male'; RUN; /* Now we will input the wolves data and create a variable for the four groups NOTE: LIBNAME p7291 must be assigned to runthis code */ *LIBNAME p7291 'path-and-directory-for-this-nickname'; DATA wolves2; SET p7291.wolves; Subject=_n_; * --- create the variable Group; group=1; IF sex='m' THEN group=2; IF location='ar' THEN group=group+2; FORMAT group wolffmt.; RUN; /* Perform the discriminant analysis This will find the three different canonical variables that best distinguish among the four groups. The results will be output to a new data set named "temp" */ PROC CANDISC DATA=wolves2 OUT=temp; VAR x1-x8; CLASS group; RUN; /* proc sort data=temp; by group; run; */ /* --- Plot the four groups on theie values on the first two canonical discriminant function --- */ PROC GPLOT DATA=temp; SYMBOL1 C=black L=1 W=3 I=none V=* H=3; SYMBOL2 C=black L=2 W=3 I=none V=> H=3; SYMBOL3 C=black L=3 W=3 I=none V=X H=3;

SYMBOL4 C=black L=4 W=3 I=none V=Y H=3; PLOT can2*can1=group; RUN; QUIT;

Das könnte Ihnen auch gefallen