Never End PROC IML with a RUN Statement


Peter Flom reminded readers of his blog that you should always end a SAS procedure with a RUN statement. This is good rule. However, PROC IML is an exception to the rule.

In PROC IML, the RUN statement is used to execute a built-in subroutine or a user-defined module. You should not use RUN as the last statement in a SAS/IML program.

If you use other SAS statistical procedures, you might find this behavior strange. In other procedures—even other interactive procedures—no statements are executed until the procedure encounters a RUN statement. Not so with PROC IML. Each statement (or block of statements) is executed as soon as you submit it.

When you are finished using PROC IML, use the QUIT statement to exit the procedure.


About Author

Rick Wicklin

Distinguished Researcher in Computational Statistics

Rick Wicklin, PhD, is a distinguished researcher in computational statistics at SAS and is a principal developer of SAS/IML software. His areas of expertise include computational statistics, simulation, statistical graphics, and modern methods in statistical data analysis. Rick is author of the books Statistical Programming with SAS/IML Software and Simulating Data with SAS.


  1. The key point, I believe, is to always conclude your use of proc IML with a QUIT. Well, the fact that RUN can mean something different within the context of IML studio is important, too. (It doesn't always mean something different, e.g. within a submit/endsubmit.)

    However, if you want to enter a "run;" after the QUIT then that is fine and it will have no effect other than to make you code structure look more regular/familiar.

  2. Pingback: SAS tip: Put ODS statements inside procedures - The DO Loop

  3. Pingback: How to stop processing your SAS/IML program if a certain condition is met - The DO Loop

  4. Pingback: The difference between RUN and CALL for SAS/IML subroutines - The DO Loop

  5. Pingback: Running interactive procedures in SAS Studio and SAS University Edition - The DO Loop

  6. Pingback: Do you write unnecessary SAS statements? - The DO Loop

Leave A Reply

Back to Top