【发布时间】:2020-09-12 15:55:33
【问题描述】:
我有以下代码,结果为 sas。它确实按小计降序排序,但是我需要报告在同一个小计中按人员降序排序。附上代码。我该怎么做呢
data have;
format setup_date date9.;
infile datalines;
input setup_date date9. Division $ Officer $ cnt;
return;
datalines;
1Jun2018 Central Smith 1
10Jun2018 Central Smith 1
10Jul2018 Central Smith 1
20Jun2018 Central Smith 1
11Jun2018 Central Shelton 1
1May2018 Central Baldwin 1
16May2018 Central Stone 1
12May2018 Central Grant 1
14May2018 Central Grant 1
1Sep2018 Central Jones 1
11Apr2019 Atlantic James 1
17Apr2019 Atlantic James 1
19Apr2019 Atlantic Smith 1
1Feb2019 Atlantic Doglass 1
14Feb2019 Atlantic Shane 1
15Feb2019 Atlantic Shane 1
16Feb2019 Atlantic Shane 1
17Feb2019 Atlantic Shane 1
;run;
proc sql;
create table report_data as
select *,
sum(cnt) as div_cnt_sum
from have
group by division;
;quit;
proc report data=report_data wrap style(summary)=Header;
columns div_cnt_sum Division WiderDivision Officer setup_date cnt ;
define div_cnt_sum / group descending noprint ;
define Division / group noprint;
define WiderDivision / 'Division' computed;
define Officer /group ;
define setup_date / across format=year4. order=internal '';
define cnt / sum f=comma6. 'Row Tot';
break after Division / summarize;
rbreak after / summarize;
compute WiderDivision / character length=25; /* specify the widerness */
WiderDivision = Division;
endcomp;
compute after;
WiderDivision='Grand Total';
endcomp;
run;
我想保留整个部门并按军官降序排列
【问题讨论】:
-
你只是缺少
order=internal吗?您在 date var 上有它,但在 count var 上没有。