As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Do which loop until or while

From sasCommunity
Jump to: navigation, search

Do Which? Loop, Until or While? A Review Of Data Step And Macro Algorithms

Author: Ronald_J._Fehd

This paper reviews the three looping constructs:

  • loop-repeat,
  • do until and
  • do while

and offers examples of their use. The purpose of this paper is to provide both pseudo-code and examples so that programmers may understand the difference in logic and make an appropriate choice for their algorithm.

The two data step loop processing verbs:

  • continue (return to loop-top), and
  • leave (exit)

are illustrated. Macro examples using %goto are shown for continue and leave. The Whitlock subsetting loop --- also known as the Do-Whitlock (DOW) loop --- and double-DOW are illustrated.

Download the zip with 20 programs used in RnD of this paper: [[1]]

References

This paper has been published several times:


To Do:

  •  %stop; probably %return does this
    • otherwise: %if &Condition. %then %goto Exit;
    •  %Exit:%mend;

-- created by User:Rjf2 10:16, 15 September 2009 (UTC)

--Ronald_J._Fehd macro.maven == the radical programmer