|
|
6#

楼主 |
发表于 2008-1-5 22:44:04
|
只看该作者
Re: 求助:一个SAS数据集转化问题!
好方法都被大家想完了,我只能拿个最拙劣的方法出来混混,哈哈。
%macro a;
proc sql;
select min(x),max(y) into :L,:H
from a;
quit;
data _null_;
dsid=open('a');
nobs=attrn(dsid,'nobs');
call symput('nobs',nobs);
rc=close(dsid);
run;
data result;
do ticks=&l to &h;
output;
end;
run;
%do n=1 %to &nobs;
data _null_;
set a;
if id=&n;
call symput('x',x);
call symput('y',y);
run;
data id;
%if &l<&x %then %do;
do ticks=&l to %eval(&x-1);
id&n=.;
output;
end;
%end;
do ticks=&x to &y;
id&n=1;
output;
end;
%if &h>&y %then %do;
do ticks=%eval(&y+1) to &h;
id&n=.;
output;
end;
%end;
run;
data result;
merge result id;
by ticks;
run;
%end;
%mend;
%a; |
|