我需要一个专栏作为观察。
Input Dataset Output Dataset
------------- --------------
data input; Name Mark
input name$ mark; a 10
datalines; b 20
a 10 c 30
b 20 Total 60
c 30
;
run;
我写的下面的代码工作正常。
data output;
set input end=eof;
tot + mark;
if eof then
do;
output;
name = 'Total';
mark = tot;
output;
end;
else output;
run;
请建议是否有更好的方法。
答案 0 :(得分:2)
PROC REPORT是一个很好的解决方案。这总结了整个报告 - 其他选项使您能够分组汇总。
proc report out=outds data=input nowd;
columns name mark;
define name/group;
define mark/analysis sum;
compute after;
name = "Total";
line "Total" mark.sum;
endcomp;
run;