proc means data=a max min;
output out=temp(drop=_type_ _freq_ );
run;
data _null_;
set temp;
if _stat_ in ('MIN') then do;
call symput('min',catx(',',of _numeric_));
end;
if _stat_ in ('MAX') then do;
call symput('max',catx(',',of _numeric_));
end;
run;
data max min;
set temp;
if _stat_ in ('MIN') then output min;
if _stat_ in ('MAX') then output max;
drop _stat_;
run;
data y;
set b;
array big{&no} _temporary_ (&max);
array small(&no) _temporary_ (&min);
array temp(*) _numeric_;
do i=1 to dim(temp);
if temp(i)<= big(i) and temp(i)>= small(i);
end;
drop i;
run; [/code:19b7gqf6]作者: shiyiming 时间: 2009-4-18 13:56 标题: Re: 如何对两个数据集进行比对? 非常感谢您的回复以及你的程度。
可能我没有把问题表述清楚,对以上问题再补充一点,希望能得到帮助!
例如:数据集a中包含
var RBC PLT ALT BUN
min 3.5 100 0 2.5
max 5.5 300 40 7.8
data _null_;
set a;
if upcase(var) in ('MIN') then do;
call symput('min',catx(',',of _numeric_));
end;
if upcase(var) in ('MAX') then do;
call symput('max',catx(',',of _numeric_));
end;
run;
data y;
set b;
array big{4} _temporary_ (&max);
array small(4) _temporary_ (&min);
array temp(*) _numeric_;
do i=1 to dim(temp);
if temp(i)>= big(i) or temp(i)<= small(i);
end;
drop i;
run; [/code:u7c6zwij]作者: shiyiming 时间: 2009-4-22 16:42 标题: Re: 如何对两个数据集进行比对? data a;
input var $ RBC PLT ALT BUN;
cards;
min 3.5 100 0 2.5
max 5.5 300 40 7.8
;
run;
%macro t;
data target;
set b;
%do i=1 %to 4;
if &&var&i > &&&&min&&var&i and &&var&i<&&&&max&&var&i then &&var&i='s';
%end;
run;
%mend;
%t作者: shiyiming 时间: 2009-4-26 00:14 标题: Re: 如何对两个数据集进行比对? [code:1fum3jk7]data a;
input var $ RBC PLT ALT BUN;
cards;
min 3.5 100 0 2.5
max 5.5 300 40 7.8
;
run;
proc sql;
create table xx as
select max(rbc) as RBCX,min(rbc) as RBCN,
max(PLT) as PLTX,min(PLT) as PLTN,
max(BUN) as BUNX,min(BUN) as BUNN,
max(ALT) as ALTX,min(ALT) as ALTN
from a;
quit;
data ex(where=(aa=0) keep=center number RBC PLT ALT BUN aa);
set xx;
do i=1 to 6;
set b;
aa=(rbcx < rbc)+(rbcn > rbc)+(pltx < plt)+(pltn > plt)
+(BUNx < BUN)+(BUNn > BUN)+(ALTX < ALT)+(ALTn > ALT);
output;
end;
run;[/code:1fum3jk7]