Without a data set this is very hard to evaulate. And the presence of macro variables without defined values makes it even more problematic to evaluate what may be going on with your code. You may also have to provide a comparion of which values are "incorrect" and what the expected value should be for given data.
If you could provide a small data step to create data that duplicates the overal behavior you'll likely get more help.
... View more