|
|
地板

楼主 |
发表于 2008-11-8 21:10:20
|
只看该作者
Re: 一个分类百分比的问题
you're so weird! I never see a real need of using ONLY data step.
[code:3npde2yf]
data _null_;
if 0 then set aa;
length count 8;
if _n_=1 then do;
declare HASH ht(ordered:'a');
ht.defineKey('id', 'type');
ht.defineData('id', 'type', 'count');
ht.defineDone();
end;
do until (eof);
set aa end=eof;
if ht.find() then
ht.add(key: id, key: type, data: id, data: type, data: 1);
else
ht.replace(key: id, key: type, data: id, data: type, data: count+1);
end;
ht.output(dataset: 'b');
data xxx;
n_id=0;
do until(last.id);
set b;
by id;
n_id++count;
end;
do until(last.id);
set b;
by id;
pct_row = count/n_id;
output;
end;
run;
[/code:3npde2yf] |
|