SAS Error – Open Code Statement Recursion Detected

When a macro variable is assigned to itself, the error open code statement recursion detected will be generated. It can occur when there are two types of mistakes that cause this error. A missing semicolon or end parenthesis or quote at the end of the %let statement causes SAS to think the variable is part of the %let statement. The next statement then uses that variable in a macro context, which leads to this error.

Also Read:How to Interpret Otis Error Codes PDF

If you encounter this error, the first thing to do is to define your recursive function. A recursive function will break complex inputs into simpler ones. The recursive function will simplify the input problem with each call, and at some point will reach the base case. However, functions that are not intended to terminate will fail to meet this requirement. Otherwise, the code will continue to produce the same error and will never reach its destination.