Search code examples
sassas-macro

SAS - Break out of macro %DO loop


I know there exists the LEAVE statement for data step DO loops to terminate the current loop. I cannot find, however, documentation for a corresponding macro command.

I've tried %LEAVE but that appears not to be defined.

  1. Does SAS not have a break statement for macro loops?
  2. If not, are there other options beside using %GOTO or a DATA _NULL_?

Solution

  • No, unfortunately there is no equivalent of leave in the macro language (as of v9.4).

    You can see a complete list of macro statements in the documentation in the Macro Language Dictionary.

    As a workaround you will have to manually trigger an exit condition for your loop.