[code:1hb930i0]proc sql;
create table out as
select stu_id,score,max(scr_cmp) as scr_cmp,
case
when score gt calculated scr_cmp then '优'
else '良'
end as eva
from score;
quit;[/code:1hb930i0]
DATA OUT;
SET SCORE(IN=A KEEP=SCR_CMP)
SCORE(IN=B);
RETAIN CMP 0;
IF A THEN DO;
IF CMP LE SCR_CMP THEN CMP=SCR_CMP;
END;
IF B;
IF SCORE GT CMP THEN EVA="优";
ELSE EVA="良";
KEEP STU_ID SCORE CMP EVA;
RUN;