/* read the raw data
*/
data
raw; infile
'd:\rawdata.txt';
input
userid 1-9
@10
(q1-q100) (1.0);
/* assign a "flag" for merging with the key set later */
inall =
1;
proc
sort;
by
userid;
run
;
/* import the key */
data
key; infile
"d:\key.txt";
input
(k1-k100) (1.0);
/* assign a "flag" for merging with the raw data later */
inall =
1;
run
;
/* merge the key and the raw data so that every record has a set of key
*/
data
new; merge
raw key; by
inall;
/* make three arrays
q is the array to hold the raw responses
k is the array to hold the key set
s is the array to hold the scores */
array
q{*}
q1-q100;
array
k{*}
k1-k100;
array
s{*}
s1-s100;
/* use a do loop to grade each raw responses into binary scores */
do
i = 1
to
100;
if
q{i} = k(i) then
s{i} = 1;
else
s{i} = 0;
end
;
drop
inall q1-q100 k1-k100 i;
run
;