data m2;
set m end=last;
nth=_n_;
if last then call symput('tot',nth);
run;
%macro loop;
%do i= 1 %to &tot;
proc sql noprint;
select x
into :y
from m2
where nth=&i;
quit;
%do j=1 to &y;
------------
%end;
%end;
%mend;
%loop;作者: shiyiming 时间: 2012-4-21 00:59 标题: Re: 怎么读取一个变量的值在另外一个数据里进行循环呢? 我刚学习用HASH;
data m;
input x ;
card;
2
6
7
;
run;
data t;
if _N_=1 then do;
dcl hash hh(dataset:"m");
declare hiter iter('hh');
hh.definekey('x');
hh.definedata("x");
hh.definedone();
call missing(x);
end;
set test1;
iter.first();
do j=1 to x;
output;* or whatever you want here;
end;
do i=2 to hh.num_items;
iter.next();
do j=1 to x;
output;* or whatever you want here;
end;
end;
drop i j x;
run;作者: shiyiming 时间: 2012-4-21 17:34 标题: Re: 怎么读取一个变量的值在另外一个数据里进行循环呢? 非常谢谢各位!