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
This paper reviews the three looping constructs:
- 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: []
This paper has been published several times:
- Do Which? Loop, Until or While? A Review Of Data Step And Macro Algorithms
- How to Use Arrays and DO Loops: Do I DO OVER or Do I DO i?
- Double your pleasure, double your words.
- David L. Cassell.
- Coders' Corner, 5 pp.; using the Whitlock DO-loop with the PRX* (Perl) functions to find doubled words in lines of text.
- The DOW (not that DOW!!!) and the LOCF in clinical trials.
- Venky Chakravarthy.
- Coders' Corner, 4 pp.; explanation of default reset of non-retained vars to missing when using first. and last. processing; do until(last.pt) replaces retain and if first.pt processing.
- The magnificent Do.
- Paul M. Dorfman.
- Topic: sequential processing, do-loop; info: do-loop terminology, DOW-loop: until(last.var), optimization, simplification.
- Retaining, laggin, leading, and interleaving data.
- Toby Dunn and Chang Y. Chung.
- Tutorials, 8 pp.; topic: retain and lag functions; info: merge, reset of values to missing, DOW-loop: until(last.var).
- cited by:
- Joel McMullin,
- Periodicity Via the SAS® Iterative Loop
- Joel McMullin,
- %stop; probably %return does this
- otherwise: %if &Condition. %then %goto Exit;
-- created by User:Rjf2 10:16, 15 September 2009 (UTC)