|
|
楼主

楼主 |
发表于 2007-9-30 13:03:00
|
只看该作者
求助!在数据步中调用另外一个宏
比如有两个数据集,t1,如下:
r1 r2 r3 r4 r5
1.1 1.4 1.3 1.5 1.9
t2,如下:
s1 s2 s3 s4 s5 s6 s7 s8 s9 s10
1.12 1.34 1.38 1.45 1.69 1.6 1.4 1.2 2.4 2.8
现在要从这两个数据集中计算出一个数,规则是这样的,i从1到11,若i=1,则y=r1对应的数1.1,若i=1.5,则取r1和r2的均值,若i=2.5,则取r2和r3的均值,若i>5,则要从t2中取,规则一样,若i=8.5,则取s8和s9的均值,若i>10,则取0.
我是通过在数据步中调用另一个宏,但总通过不了,请问各位高手,问题出在哪?
程序如下:
%macro aaa;
%do i=1 %to 11 %by 0.5;
data _null_;
set t1;
array r(*) _all_;
do j=1 to dim(r);
if &i.<=dim(r) and j<=&i. and j>(&i.-1) then y=(r(j)+r(j+1))/2;
if &i.>dim(r) then do;
%bbb;
y=&yy.;
end;
run;
call symput("y",y);
%put _user_;
%mend aaa;
%aaa;
%macro bbb;
data _null_;
set t1;
array s(*) _all_;
do j=1 to dim(s);
if &i.<=dim(s) and j<=&i. and j>(&i.-1) then yy=(s(j)+s(j+1))/2;
if &i.>dim(s) then yy=0;
call symput("yy",yy);
end;
run;
%mend bbb; |
|