From: xlr82sas on
On Feb 26, 11:17 pm, kuh...(a)126.COM (Clark An) wrote:
> I think you are better of learning what the lag&i.(x) means...
> Data step Do loop to change the value of Macro Variable as the topic
> mentioned, I wanna instead the %do loop with data step do loop.
>
> Thank you.

Hi Clark An,

Do whatever you like with the N array. I am not sure you want. I used
I-1.

data mat2345;
retain n 0;
array x[2,3,4,5] x1-x120;
array nx[120] nx1-nx120;
/* do whatever you want here to define the n's */
/* I used i-1 but you can do something else */
do i=1 to 120;
n+1;
nx[i]=i-1;
end;
n=1;
do i=1 to 2;
do j=1 to 3;
do k=1 to 4;
do l=1 to 5;
x[i,j,k,l]=nx[n];
n+1;
end;
end;
end;
end;
output;
run;

Here is what the output looks like

X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17