/* Reading the husband-wife data into SAS */ DATA huswif; INPUT Hage Hheight Wage Wheight Hagefm; cards; 49 1809 43 1590 25 25 1841 28 1560 19 40 1659 30 1620 38 52 1779 57 1540 26 58 1616 52 1420 30 32 1695 27 1660 23 43 1730 52 1610 33 47 1740 43 1580 26 31 1685 23 1610 26 26 1735 25 1590 23 ; run; /* Getting a covariance matrix, correlation matrix and mean vector in SAS */ PROC CORR DATA = huswif COV NOPROB; VAR Hage Hheight Wage Wheight Hagefm; RUN; /* Getting just the correlation matrix */ PROC CORR DATA = huswif NOSIMPLE NOPROB; VAR Hage Hheight Wage Wheight Hagefm; RUN; /* Getting normal Q-Q plots for each variable in SAS: */ PROC UNIVARIATE DATA=huswif NOPRINT; QQPLOT; RUN; /* Getting a chi-square plot in SAS */ PROC IML; USE huswif; READ ALL INTO X; N=NROW(X); SUMX=X[+,]; S=(T(X)*X-T(SUMX)*SUMX/N)/(N-1); XBAR=SUMX/N; OBSVALS=VECDIAG((X-(J(N,1)*XBAR))*INV(S)*T(X-(J(N,1)*XBAR))); EXPVALS=CINV((RANK(OBSVALS)/(N+1)),NCOL(X)); CREATE CHIPLOT VAR {OBSVALS EXPVALS}; APPEND; QUIT; PROC GPLOT DATA=CHIPLOT; PLOT EXPVALS*OBSVALS; RUN; /* **************************************************************** */ /* Reading in the fisher iris data set from a file */ DATA iris; INFILE 'z:\My Documents\teaching\stat_530\fisheriris.txt' firstobs=2; INPUT ObsNo Sepal_Length Sepal_Width Petal_Length Petal_Width Species $; run; /* Creating 3 data sets that are subsets of the iris data, according to Species */ DATA seto; SET iris; IF Species = 'setosa'; run; DATA vers; SET iris; IF Species = 'versicolor'; run; DATA virg; SET iris; IF Species = 'virginica'; run; /* Try the chi-square plot on the iris data, and on the subsets ... */