From: Ya Huang on
Hi there,

I'm surprised that "do over" can't be nested. See the following.
The first data step tried to nest two "do over" and got error message.
The second one used explicit reference to the array and worked as
expected. Wonder why? Is it because do over always use the same index var,
so the inner loop changes the outer loop index?

Thanks

Ya

1 data _null_;
2 array x a1-a3 (3*0);
3 array y b1-b4 (4*1);
4 do over x;
5 do over y;
6 put x= y=;
7 end;
8 end;
9 run;

a1=0 b1=1
a2=0 b2=1
a3=0 b3=1
ERROR: Array subscript out of range at line 6 column 4.
_I_=4 a1=0 a2=0 a3=0 b1=1 b2=1 b3=1 b4=1 _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


10
11 data _null_;
12 array x a1-a3 (3*0);
13 array y b1-b4 (4*1);
14 do i=1 to dim(x);
15 do j=1 to dim(y);
16 put x(i)= y(j)=;
17 end;
18 end;
19 run;

a1=0 b1=1
a1=0 b2=1
a1=0 b3=1
a1=0 b4=1
a2=0 b1=1
a2=0 b2=1
a2=0 b3=1
a2=0 b4=1
a3=0 b1=1
a3=0 b2=1
a3=0 b3=1
a3=0 b4=1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds