Proc Report降序排列

问题描述 投票:0回答:1

我有以下代码,结果为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;

我想保留整个部门并按人员降序排列>

我有以下代码,结果为sas。它确实按小计对降序进行排序,但是我需要该报告按同一小计中的人员对命令进行降序排序。随附代码。我该怎么办...

sorting sas report proc
1个回答
1
投票

您必须预先计算division和以按组和排序。现在,您想按officerdivision上的组总和进行附加排序。为了做到这一点(双关语意),您将需要遵循相同的方法。通过组组合预先计算每个division officer的总和,并在报告的另一个noprint列中使用它们。

© www.soinside.com 2019 - 2024. All rights reserved.