我需要一个带有自定义摘要的报告,下一个报告显示测试数据集中的字段,总结果是每个变量的总和。我希望总值是变量num的总和除以tot变量的总和。即68/194 = 35.05%,而不是比率变量中的百分比之和。
data test;
input rank num tot rate;
datalines;
1 20 50 0.4
2 15 30 0.5
3 28 52 0.538461538461538
4 5 62 0.0806451612903226
;
run;
proc report data = _last_ box spacing = 1 split = "/"
style(header) = [font_face = "courier new"] style(column) = [font_face =
"courier new"]
style(lines) = [font_face = "courier new"] style(report) = [font_face =
"courier new"]
style(summary) = [font_face = "courier new" font_style = roman];
column(rank num tot rate);
define rank / " Rank " center width = 6 format = 5. order
order = data;
define num / " N " center width = 6 format = 5.;
define tot / " Total " center width = 6 format = 5.;
define rate / " Rate " center width = 6 format =
percent9.2 ;
rbreak after / summarize style = [font_weight = bold];
run;
答案 0 :(得分:0)
您快到了-我想您在analysis mean
变量define
时只需指定rate
:
data test;
input rank num tot rate;
datalines;
1 20 50 0.4
2 15 30 0.5
3 28 52 0.538461538461538
4 5 62 0.0806451612903226
;
run;
proc report data = _last_ box spacing = 1 split = "/"
style(header) = [font_face = "courier new"] style(column) = [font_face =
"courier new"]
style(lines) = [font_face = "courier new"] style(report) = [font_face =
"courier new"]
style(summary) = [font_face = "courier new" font_style = roman];
column(rank num tot rate);
define rank / " Rank " center width = 6 format = 5. order order = data;
define num / " N " center width = 6 format = 5.;
define tot / " Total " center width = 6 format = 5.;
define rate / " Rate " center width = 6 format = percent9.2 analysis mean;
rbreak after / summarize style = [font_weight = bold];
run;
quit;
答案 1 :(得分:0)
汇总后添加计算块。
proc report data = _last_ box spacing = 1 split = "/"
style(header) = [font_face = "courier new"] style(column) = [font_face =
"courier new"]
style(lines) = [font_face = "courier new"] style(report) = [font_face =
"courier new"]
style(summary) = [font_face = "courier new" font_style = roman];
column(rank num tot rate);
define rank / " Rank " center width = 6 format = 5. order
order = data;
define num / " N " center width = 6 format = 5.;
define tot / " Total " center width = 6 format = 5.;
define rate / " Rate " center width = 6 format =
percent9.2 ;
rbreak after / summarize style = [font_weight = bold];
compute after;
rate.sum=num.sum/tot.sum;
endcomp;
run;