|
地板

楼主 |
发表于 2011-7-5 21:07:22
|
只看该作者
Re: 如何定义group
为什么用indexw而非index呢?查了一下,感觉差不多啊。另外为什么用cats(x)而不直接x?直接x也可以run出来结果。
[quote="hopewell":3092qyu1][code:3092qyu1]data a;
input id $ x;
cards;
a 0
a 11
a 1
a 11
b 3
c 0
c 3
d 2
d 2
e 1
;
data b;
length x_grp $50;
do _n_=1 by 1 until(last.id);
set a;
by id notsorted;
if indexw(trim(x_grp),cats(x),'_')=0 then x_grp=catx('_',x_grp,x);
end;
do _n_=1 to _n_;
set a;
output;
end;
run;[/code:3092qyu1][/quote:3092qyu1] |
|