TEST SOLUTIONS, Stat 430 In-Class Test S09 ANSWERS: I. (a) PROC FREQ data=home.times; tables AMT * GRP / norow nocolumn nocum nopercent ; (b) PROC CORR data=home.times; var liftim; with amt; /* for partial correlation add the line */ partial grp; (c) PROC MEANS DATA=HOME.TIMES min max; var LIFTIM; class AMT GRP ; output out=homout min=LIFMIN max=LIFMAX; data homrang(keep = AMT GRP RANGE); set homout; RANGE = LIFMAX-LIFMIN; if AMT ne . and GRP ne . ; proc print data=homrang; run; This whole problem part could also have been done using the OUTPUT statement from PROC UNIVARIATE. For OUTPUT unlike the printed output, you can specify what statistics will be calculated, and RANGE is an allowed keyword for that output. As it turns out, in current version of SAS "range" is also an allowed statistic keyword for PROC MEANS, so that (using range in place of min max) is definitely the best way to do problem I(c). (d) PROC UNIVARIATE data=home.times ; histogram liftim; class grp; run; or PROC GCHART data=home.times; vbar liftim / group = grp ; run; In either case, you wanted to specify as an option: LEVELS=5 , or midpoints a to b by c II. (a) Needed to plot step function with upward jumps of 1/8 at each observation except for 7, whre the jump is 1/4. Find quantile as midpoint of interval of values for which the empirical distribution function crosses or is equal to the fraction (1/4 for Q1, 1.2 for median) desired. > quantile(tdat,c(.25,.5), type=2) 25% 50% 6 7 (b). > hist(tdat, breaks=seq(4,14,2), plot=F)[c(1,2,4,5)] $breaks [1] 4 6 8 10 12 14 $counts [1] 2 3 0 2 1 $density [1] 0.1250000 0.1875000 0.0000000 0.1250000 0.0625000 $mids [1] 5 7 9 11 13 NOTE observation falling on interval boundary (III.) Discussed in class. Words matter !