Hello,
I'm a new SAS user, so thanks in advance for your help. 🙂
I have a loop inside a loop that puts x variable values into an array, and then the outer loop iterates y times. When it iterates the next y time, I want the array to keep the previous values and add the new values to that array instead of replacing the previous values (I assume that if I use retain, it would stop it from replacing but not add the new ones). This is my basic code.
1 do y = 1 to 5;
2 if array1[y] ~= . then
3 do x = 1 to 3;
4 if array2[x] = . or array2[x] < array1[y] then array3[x] = .;
5 else array3[x] = array2[x] - array1[y];
6 end;
7 else do x = 1 to 3;
8 array3[x] = .;
9 end;
10 end;
I tried adding this before the last end statement (so it is included in the y iteration):
Z = 1; (specified outside of loops)
11 do j = 1 to 3;
12 array4[Z] = array3[j];
13 Z+1;
14 end;
15 Z+1;
...but it says there's an array subscript out of range at line 12.
I've attached the actual code I used.
Ideas???