Your interior DO / END loop is executing 9 times, regardless of the fact that you have assigned your new variable. I would suggest setting one of the following:
1) use the LEAVE statement to exit your DO loops, when appropriate.
2) assign both of your DO/END looping variables when you want to continue / iterate to the next observations, using the DIM(i) function in your assignment statement (better than assigning an explicit max value).
Also, adding some PUTLOG " " / _ALL_; statements will help you see the processing -- consider setting up multiple PUTLOGs and use a unique "nn" value for each distinct statement, for easier identification.
Scott Barry
SBBWorks, Inc.
... View more