Generating Data with DO Loops |
Lesson
Overview |
Introduction
You can execute SAS statements repeatedly by placing them in a DO loop. Unlike simple DO statements, which execute as a group when an IF condition is met, DO loops execute any number of times in a single iteration of the DATA step. Using DO loops lets you write concise DATA steps that are easier to alter and debug. For example, the DO loop in this program eliminates the need for 12 separate programming statements to calculate annual earnings: data finance.earnings; set finance.master; Earned=0; do count=1 to 12; earned+(amount+earned)*(rate/12); end; run; You can also use DO loops to
This lesson shows you how to construct DO loops and include them in your programs. This lesson contains 31 pages and takes approximately 45-60 minutes to complete.
After completing this lesson, you will be able to
Before taking this lesson, you should have completed the following lessons: Getting Started with SAS Programming |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.