Ryomac 发表于 2014-8-24 09:29
我现在有6月份公司规模百分位数,有20%、40%、60%、80%的,想把其他月份公司的size按照这个百分位数划分相 ...
You even don't need a left join if I understand the problem correct.
Here is a simple example with the logic.
data sales;
do month=1 to 6;
n=ranuni(123)*1000;
do id=1 to n;
sales=round(ranuni(123)*10000 ,1);
output;
end;
end;
run;
proc means data=sales noprint;
var sales;
output out=pctls p20=p20 p40=p40 p60=p60 p80=p80 ;
where month=6 ;
run;
proc sql;
create table size_assign
as select month, sales,
case when sales<=p20 then 's1'
when p20<sales<=p40 then 's2'
when p40<sales<=p60 then 's3'
when p60<sales<=p80 then 's4'
else 's5'
end as size_port
from sales , pctls
;
quit;
proc print;run;