While Tom is 100% correct about learning SAS language before learning macro language, here are some secondary considerations.
The problem may lie inside the definition of %FILTER_NAME. Some possibilities:
SAS names are limited to 32 characters. Since you are already starting with a string "output_filename_YAHOO" before the macro begins, it is conceivable that the execution of %FILTER_NAME creates a name longer than 32 characters.
It is possible that %FILTER_NAME utilizes a macro variable named i. If that's the case, and there is no %LOCAL statement within %FILTER_NAME, then the interior macro (%FILTER_NAME) will change the value of i that is used to loop in the exterior macro (%LOOP).
If you were to post more of what is inside your macro, you may find you receive more than debugging help ... how to achieve the same result in a cleaner, more efficient way.
... View more