It is possible for all tests for a given subject are missed? Suppose a subject 1004 had Test 1 and Test 2 (both missed). It may be adventitious to have a separate list of given tests and then compare if the original list has matching records in this bank list of all tests given by subject. I use SQL all day so I found it easier to use PROC SQL for this. data have;
input subj $ test & $ status & $20. frq;
datalines;
1001 Test 1 Done 1
1001 Test 2 Done 1
1001 Test 3 Done 1
1002 Test 1 Done 1
1002 Test 3 Missed previous 1
1003 Test 3 Missed previous 2
;
run;
data bank;
input subj $ test & $;
datalines;
1001 Test 1
1001 Test 2
1001 Test 3
1002 Test 1
1002 Test 2
1002 Test 3
1003 Test 1
1003 Test 2
1003 Test 3
1004 Test 1
1004 Test 2
;
run;
PROC SQL;
Create Table temp AS
SELECT
tbl1.subj AS Subject
, tbl1.test AS Test
, CASE WHEN MISSING(Tbl2.subj) THEN 'Missed' ELSE 'Done' END AS Status
FROM work.bank as tbl1
LEFT JOIN work.have as tbl2
ON tbl1.subj = tbl2.subj
AND tbl1.test = tbl2.test
;
QUIT;
PROC SORT DATA = temp Out = Temp2;
BY Subject Test;
RUN;
PROC PRINT DATA = Temp2; run;
... View more