This is my 1st time asking a question in this forum. I've used SAS/Proc SQL for about 4 years, but I'm not a code-Jedi so please give detailed answers, and am fairly new to arrays, so forgive if my question is poorly detailed/explained. I am 100% comfortable building/using simple arrays in general. But I have a very specific challenge that I cannot figure out... Hard to put into words, so this may get long winded but here goes...
For basic understanding of what I am trying to accomplish, it's somewhat similar to a simple loan amortization where month 1 the balance is the original loan amount, let's say $10,000, month 2 the balance is orig_ln_amt minus any new principal/interest payment minus any additional payment resulting in lets say $9500, month 3 results in $9000 etc.... Easy for 1 account, but I'm building an array that in effect gives the forecasted total remaining balance when all active accounts are rolled together for each month into the future, so I'm using an array that changes in size each month based on the age of the accounts.
Here's some sample code that I hoped would work:
DATA SAMPLE;
SET INPUT_DATA; 'HAS EACH OF THE 3 INPUT ARRAYS LAID OUT SIDE BY SIDE BY SIDE
ARRAY_ONE {193} ARRAY_ONE1-ARRAY_ONE193;
ARRAY_TWO {97} ARRAY_TWO1-ARRAY_TWO97;
ARRAY_THREE {97} ARRAY_THREE1-ARRAY_THREE97;
OUTPUT_ARRAY {193} OUTPUT_ARRAY1-OUTPUT_ARRAY193; 'PORTFOLIO BALANCE EACH FUTURE MONTH
DO I = 1 TO 193;
OUTPUT_ARRAY[I] = sum(of ARRAY_ONE[I]-ARRAY_ONE193) - sum(of ARRAY_TWO[I]-ARRAY_TWO97) - sum(of ARRAY_THREE[I]-ARRAY_THREE97);
END;
RUN;
The problem is SAS doesn't like the [I[ iteration reference inside the array calculation. I've also tried &I based on a solution another online user received in what seemed to be a similar problem. The logic makes sense and seems like it should work in theory, but doesn't...
So we've had to manually manipulate and code each of the 193 calculations:
OUTPUT_ARRAY1 = sum(of ARRAY_ONE1-ARRAY_ONE193) - sum(of ARRAY_TWO1-ARRAY_TWO97) - sum(of ARRAY_THREE1-ARRAY_THREE97);
OUTPUT_ARRAY2 = sum(of ARRAY_ONE2-ARRAY_ONE193) - sum(of ARRAY_TWO2-ARRAY_TWO97) - sum(of ARRAY_THREE2-ARRAY_THREE97);
...
OUTPUT_ARRAY97 = sum(of ARRAY_ONE97-ARRAY_ONE193) - sum(of ARRAY_TWO97-ARRAY_TWO97) - sum(of ARRAY_THREE97-ARRAY_THREE97);
OUTPUT_ARRAY98 = sum(of ARRAY_ONE98-ARRAY_ONE193);
...
OUTPUT_ARRAY193 = sum(of ARRAY_ONE193-ARRAY_ONE193);
Seems like there should be an easy solution, but we can't figure it out. Thanks in advance for any help you all can give.