[code:227d2]%macro test;
data t2;
set t1;
%do i=1 %to 10;
if abs(x&i.)>5 then delete;
%end;
run;
%mend;
%test [/code:227d2]
如用%if...%then语句,delete和abs都会有问题,不知为什么?
另外,这个问题不用宏也好解决,如下
[code:227d2]data t2;
set t1;
array arr x1-x10;
do over arr;
if abs(arr)>5 then delete;
end;
run;[/code:227d2]
%macro test;
data _null_;
%do i=1 %to 8;
%if &i<5 %then %do;
put 'i is less than 5';
%end;
%else %do;
put 'i is greater than 5';
%end;
%end;
run;
%mend test;
%test;