我想在 proc iml 中使用宏循环,如下所示:
%Let Tab1=FirstTable;
%Let Tab2=SecondTable;
%Let Tab3=ThirdTable;
*&Tab1-3 have been initialised as sas datasets;
proc iml;
* This works;
use &Tab1;
read all into Mat3;
print Mat3;
* This doesn't work;
%Macro Define_mx;
%do i=1 %to 2;
use &Tab&i;
read all into Mat&i ;
%end;
%Mend Define_mx;
%Define_mx;
*The two matrixes have not been initialised;
print Mat1;
print Mat2;
quit;
实际上,我将不得不初始化 50 个矩阵,因此需要一个 do-loop。我无法弄清楚为什么循环不能将 &Tab&i 视为宏变量。我还尝试了使用 substr 连接变量名称的普通(非宏)do-loop 的解决方法,但它也不起作用。我在这里想念什么?