/* import data from spreadsheet; variables include binary variables
for each time period Mo8a, Mo10a, Mo12p, Mo2p, Mo4p, Mo6p, Mo8p,
Tu8a, etc., as well as an id variable and binary indicators for
computing and analytical skills */
proc import
datafile="survey.xls"
out=work.survey;
run;
/* data needs to be transposed for use in proc corr so that students
are the ``variables'' and time periods are the ``cases'' */
proc transpose
data=work.survey
out=work.surveyt;
var Mo8a Mo10a Mo12p Mo2p Mo4p Mo6p Mo8p
Tu8a Tu10a Tu12p Tu2p Tu4p Tu6p Tu8p
We8a We10a We12p We2p We4p We6p We8p
Th8a Th10a Th12p Th2p Th4p Th6p Th8p
Fr8a Fr10a Fr12p Fr2p Fr4p Fr6p Fr8p
Sa8a Sa10a Sa12p Sa2p Sa4p Sa6p Sa8p
Su8a Su10a Su12p Su2p Su4p Su6p Su8p;
id id;
run;
/* calculate pairwise pearson correlations between each student */
proc corr
noprint
data=work.surveyt
outp=work.correlations;
run;
/* create a data matrix of correlations from the proc corr output by
removing the mean, standard deviation, and sample size rows, and
the ``type'' column */
data correlations;
set correlations;
where _type_="CORR";
drop _type_;
output;
run;
/* transform correlations into differences by subtracting from 1 */
data differences(drop=i);
set correlations;
array dataarray(*) _numeric_;
do i = 1 to dim(dataarray);
dataarray(i) = 1-dataarray(i);
end;
run;
/* run metric multidimensional scaling on the differences matrix */
proc mds
data=work.differences
level=ratio
out=work.coefficients;
run;
/* create dataset from output with id numbers and map coefficients */
data work.coefficients;
set work.coefficients;
/* id=put(substr(put(_name_,$3.),2,2),$2.); */
id=_name_;
where _type_="CONFIG";
drop _name_ _dimens_ _label_ _type_ _matrix_;
run;
/* add a variable indicating whether students have computing or
analytical skills */
data work.survey;
merge work.survey work.coefficients;
skills=(Computing=1)or(Analytical=1);
keep id dim1 dim2 skills;
run;
/* display map showing the students labeled by id number and marked
according to whether they have computing/analytical skills */
goptions reset=all;
symbol1 pointlabel = ("#id") value=circle color=blue;
symbol2 pointlabel = ("#id") color=red;
proc gplot
data=work.survey;
plot dim1*dim2=skills;
run;
quit;