I think there is a typo in the var3 score, it should be 15, not 16.5. data have; infile datalines dlm=',' dsd; input Record $ var1 var2 var3; datalines; "Record1", 1,2,2 "Record2 ",1,2,2 "Record3 ",1,2,2 "Record4 ",2,3,3 "Record5 ",1,1,1 "Record6",3,3,3 "Record7",1,3,3 "Record8",3,4,1 "Record9",1,4,1 "Record10",4,4,3 ; data points; input question $ response score; datalines; var1 1 1 var1 2 0 var1 3 0.5 var1 4 . var2 1 2 var2 2 0 var2 3 1 var2 4 . var3 1 3 var3 2 0 var3 3 1.5 var3 4 . ; proc transpose data=have out=temp name=question; var var1-var3; by record notsorted; run; proc sql; create table questionScores as select T.question label="Question", count(score) as applicable, M.scoreMax*calculated applicable as highestPossible, sum(score) as pointsAwarded, calculated pointsAwarded/calculated highestPossible as questionScore from temp as T, points as P, (select question, max(score) as scoreMax from points group by question) as M where T.question=P.question and T.COL1=P.response and T.question=M.question group by T.question, M.scoreMax; create table totalScore as select sum(pointsAwarded) as totalAwarded, sum(highestPossible) as totalPossible, calculated totalAwarded / calculated totalPossible as score from questionScores; quit; proc sql; title "Question scores"; select * from questionScores; title "Total score"; select * from totalScore; quit; PG
... View more