를 해결하지 않으면 아무도 말해 줄 수 :SAS 매크로 마 루프
/*put all transaction table names into a data set*/
/*(table names are of format transac_20130603_20130610 (date from and date to)*/
data transaction_tables;
set SASHELP.VTABLE (keep=libname memname);
where lowcase(substr(memname,1,8))='transac_'
run;
/*sort and add rownumbers*/
proc sql;
create table transaction_tables as
select *, monotonic() as rownum
from transaction_tables
order by memname;
run;
/*find rownumber of first and last transaction tables with run dates before campaign start and after end date of campaign*/
data _NULL_;
set transaction_tables;
if substr(memname,9,8)<=&pre_period_start. and substr(memname,18,8)>=&pre_period_start. then do;
call symput("r1", rownum);
stop;
end;
run;
data _NULL_;
set transaction_tables;
if substr(memname,9,8)<=&max_enddate. and substr(memname,18,8)>=&max_enddate. then do;
call symput("r2", rownum);
stop;
end;
run;
%put &r1; %put &r2;
/*r1 = 11, r2 = 27 - both resolving OK*/
/*get all relevant transaction table names where rownumbers are between r1 and r2*/
/*r1=11 and r2=27 so my transaction table name macros should run from t_0 to t_16/*
%macro trans;
%let y = %eval(&r2 - &r1);
%do i=0 %to &y;
data _NULL_;
set transaction_tables;
if rownum = &r2 - (&r2 - &r1 - &i) then do;
call symput("t_&i", cats(libname, '.', memname));
stop;
end;
%end;
%mend trans;
%trans;
%put &t_0;
--WARNING: Macro variable "&t_0" was not resolved
내가 완전히 확실하지 않다하지만 왜 문제가에게 있습니다 내가 생각하는 변수의 몇 가지로 장난에서 테이블 이름을 t_ & 매크로에 할당하려고하는 마지막 부분. 나는 문제가 다른 매크로 변수를 호출하려고 시도하는 동안 매크로 변수의 이름을 지정하는 것으로 생각한다. (매크로가 0 = 0 일 때 &을 호출하여 매크로 t_0을 만들려고 시도한다.) 나는 내가 문법을 가지고 뭔가를 망쳤다 고 생각한다. 왜냐하면 은 로직이 상당히 건강하다고 생각하기 때문이다.
감사합니다.
매크로 문제를 해결하는 좋은 방법은 코드없이 매크로를 실행하는 것입니다. 당신이하는 모든 일은 코드 대체입니다 ... 코드를 실행하기 위해서는 매크로 코드를 한 번에 조금씩 넣기 만하면됩니다. –