SAS的宏文本替代功能, 同样的两段程序, 实现的是同样的功能.
%let numVar = 6; *输入你所需要的变量个数;
%MACRO arrayInput;
DATA array;
array var{&numVar} &varx_1-&&varx_&numVar;
do i = 1 to &numVar;
var{i} = i**2;
if i = &numVar then output;
end;
RUN;
%MEND arrayInput;
DATA array;
array var{&numVar} &varx_1-&&varx_&numVar;
do i = 1 to &numVar;
var{i} = i**2;
if i = &numVar then output;
end;
RUN;
%MEND arrayInput;
%arrayInput
option mprint mlogic;
%MACRO arrayInputMacro;
DATA arrayMacro;
%do i = 1 %to &numVar;
&&varx_&i = &i**2;
%end;
RUN;
%MEND arrayInputMacro;
%arrayInputMacro