我想通过以下代码合并几个单独的数据集。但是,它报告错误为: 我怎么能解决这个问题?
%macro test(sourcelib=,from=);
proc sql noprint; /*read datasets in a library*/
create table mytables as
select *
from dictionary.tables
where libname = &sourcelib
order by memname ;
select count(memname)
into:obs
from mytables;
%let obs=&obs.;
select memname
into : memname1-:memname&obs.
from mytables;
quit;
data full;
set
%do i=1 %to &obs.;
&from.&&memname&i;
%end;
;
run;
%mend;
%test(sourcelib='RESULT',from=RESULT.);
答案 0 :(得分:1)
您的%DO
循环在SET
语句中间生成了额外的分号。
set
%do i=1 %to &obs.;
&from.&&memname&i
%end;
;
为什么你有两个宏参数来传递相同的信息?你应该能够传入libref。还有为什么要做这么多的宏变量?
%macro test(sourcelib=);
%local memlist ;
proc sql noprint;
select catx('.',libname,memname) into :memlist separated by ' '
from dictionary.tables
where libname = %upcase("&sourcelib")
order by 1
;
quit;
data full;
set &memlist ;
run;
%mend;
%test(sourcelib=ReSulT);