SAS Training Day4 - SAS Training Day4 SAS Processing data...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
SAS Training – Day4 SAS Training – Day4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Processing data iteratively and Combining data sets. DO Loop Processing Statements with in a DO loop executes for a specific number of iterations or until a specific condition stops the loop. DO loop is used to perform perform repetitive calculations generate data eliminate redundant code execute SAS code conditionally
Background image of page 2
3 Processing data iteratively and Combining data sets. DO Loop Processing The iterative DO statement executes statements between DO and END statements repetitively based on the value of an index variable. General form of the iterative statement DO index-variable=specification-1 <….specification-n>; <additional SAS statements> END; Index-variable names a variable whose value governs execution of the DO loop Specification-1….specification-n can represent a range of values or a list of specific values. Note: The index variable unless dropped is included in the data set that is being created.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Processing data iteratively and Combining data sets. DO Loop Processing Type:1 DO index-variable=start TO stop <BY increment>; start – specifies the initial value of the index variable. stop - specifies the ending value of the index variable. Increment – optionally specifies a positive or negative number to control the incrementing of index-variable. If no increment is specified, the index variable is incremented by 1. The values of start, stop and increment are established before executing the loop. Start, stop and increment must be numeric or expressions that yield numbers. Any changes to the value of STOP or increment made within the DO Loop do not affect the number of iterations.
Background image of page 4
5 Processing data iteratively and Combining data sets. DO Loop Processing Example for Type 1 do i=1 to 12 by 4; do m=3.5 to 2.5 by -0.05; do k = Begindate to Today() by 7; Type:2 DO index-variable=item-1, <…item-n>; Item-1 through item-n can be either all numeric or all character constants or they can be variables. The DO loop is executed once for each value in the list. Example for Type 2 do Month = ‘JAN’, “FEB’, MAR’; do Fib = 1,2,3,4; do i=var1, var2, var3;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Processing data iteratively and Combining data sets. DO Loop Processing Do Loop Logic Initialize PDV Execute “read” statement EOF Marker? Stop DATA Step Execute program statements do index=start to stop by increment; SAS-statement end; Execute additional Program statements Output observation to SAS data set Define start, stop and increment Values. Set INDEX = start. Is Index Out of range? Execute statements in loop INDEX = INDEX + increment YES YES NO NO
Background image of page 6
7 Processing data iteratively and Combining data sets. DO Loop Processing DO Loop Execution data invest; do Year= 2001 to 2003 ; Capital+ 5000 ; Capital+(Capital* .075 ); end ; run ; YEAR CAPITAL _N_ 2001 0 1 D
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Processing data iteratively and Combining data sets. DO Loop Processing
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/08/2010 for the course USE 3425 taught by Professor Raman during the Spring '10 term at Punjab Engineering College.

Page1 / 45

SAS Training Day4 - SAS Training Day4 SAS Processing data...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online