如果随便分的话,简单举个步骤
/*按月份分类计数*/
proc sort data=temp;
by month company;
run;
data temp;
set temp;
by month company;
if first.month then aa=1;
else aa+1;
run;
/*五等分,将计数的aa除以5取余数,按照month + 余数为0、1、2、3、4分为五组*/
data temp;
set temp;
bb=mod(aa,5);
run;
data a;
set a;
by a b;
if first.a then a1=1;
else a1+1;
run;
proc sql;
create table b as
select *,int(max(a1)/10) as a2,mod(max(a1),10) as a3
from a group by a;
quit;
proc sort data=b;
by a b;
run;
data c;
set b;
a4=(a2+1)*a3;
if a1<=a4 then cls=compress(a||'1');
else cls=compress(a||'2');
run;
data c;
set c;
by cls b;
if first.cls then c1=1;
else c1+1;
run;
data d;
set c;
by cls;
if first.cls then a5=1;
else do;
if substr(cls,2,1)='1' and mod(c1,(a2+1))=1 then a5+1;
if substr(cls,2,2)='2' and mod(c1,a2)=1 then a5+1;
end;
run;
data d;
set d;
cl=compress(cls||a5);
keep a b cl;
run;