After we get cumulative percentage, we format the percentage with put function. Take care in the proc format don't forget to add hlo, otherwise it will gives error since the first start number is missing.
data test;
do i=1 to 1000;
x=ranpoi(8,8);
output;
end;
run;
data test;
set test;
y+x;
run;
proc sql;
create table test as
select x, y, y/max(y) as pct
from test;
quit;
data test2;
do i=1 to 100;
x=i/100;
y=lag(x);
output;
end;
run;
data a;
set test2;
fmtname='fmttestf';
start=y;
end=x;
label=i;
eexcl='Y';
if _n_=1 then hlo='L';
run;
proc format cntlin=a;
select fmttestf;
run;
data final;
set test;
rank=put(pct, fmttestf.)+0;
run;
proc print data=final;
run;
proc sql;
select rank, count(1) as cnt
from final
group by rank
order by rank;
quit;
No comments:
Post a Comment