Sorting 进程报告降序排序
我在sas中有以下代码和结果。它确实按小计降序排序,但是我需要报告在同一小计中按官员降序排序。随函附上代码。我该怎么做Sorting 进程报告降序排序,sorting,sas,report,proc,Sorting,Sas,Report,Proc,我在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
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;
我想保持整体分区和排序按官员降序您必须预先计算分区和,以便按组和排序。现在,您需要在
部门
内的官员
上按组和进行额外订购。为了做到这一点,你需要遵循同样的方法。按组组合预先计算每个部门官员的总和
,并在报告的另一noprint
列中使用它们
例如:
data have;
format setup_date date9.;
infile datalines;
input setup_date date9. Division $ Officer $ cnt;
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
;
* nested queries for computing sums of two different by groups;
* grouping by division is the nested sub-query and a new outer scope
* computes the sums for division,officer;
proc sql;
create table report_data as
select *,
sum(cnt) as div_off_cnt_sum
from
(
select *,
sum(cnt) as div_cnt_sum
from have
group by division
)
group by division, officer
;
quit;
proc report data=report_data wrap style(summary)=Header;
columns
div_cnt_sum /* to be used for ordering by group sum */
Division
WiderDivision
div_off_cnt_sum /* officer within division sum(cnt) */
Officer
setup_date
cnt
;
/* precomputed group sums for custom ordering by totals when /across in effect */
define div_cnt_sum / group descending noprint;
define div_off_cnt_sum / group descending noprint;
define Division / group noprint;
define WiderDivision / 'Division' computed;
define Officer / group descending;
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;
WiderDivision = Division;
endcomp;
compute after;
WiderDivision='Grand Total';
endcomp;
run;
您是否只是缺少
订单=内部?在日期变量上有,但在计数变量上没有。