|
|
沙发

楼主 |
发表于 2008-11-16 13:17:04
|
只看该作者
Re: 请教:多个变量的比较问题
I'm not sure, but something like the 2nd data step may work out.
[code:27vhwl2d]
data a;
array b[*] b1-b12;
array q[*] q1-q10;
do k=1 to 10;
do i=1 to dim(b);
b[i] = floor(ranuni(0)*5);
if b[i] = 0 then b[i]=.;
end;
do i=1 to dim(q);
q[i] = floor(ranuni(0)*5);
if q[i] = 0 then q[i]=.;
end;
output;
end;
drop k i;
format b1-b10 q1-q10 1.;
data inclusive not_inclusive;
array b[*] b1-b12;
array q[*] q1-q10;
set a;
str = peekclong(addrlong(q[1]), 8*dim(q));
count_diff = 0;
do i=1 to dim(b);
if index(str, put(b[i], rb8.))=0 then count_diff++1;
end;
if count_diff>0 then output not_inclusive; else output inclusive;
drop i str count_diff;
proc print data=inclusive;
proc print data=not_inclusive;
run;
*proc export ... ...;
[/code:27vhwl2d]
it is more efficient if you sort arrays b and q first, then compare their elements from left to right. |
|