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 statement

From sasCommunity
Jump to: navigation, search

The DO statement is used in the DATA Step to group several statements that should be executed together, usually as a conditional DO group or in an iterative manner for a single observation.

Syntax

Simple DO group

DO ;
Zero or more statements;
END ;

Simple DO group usage

Simple DO groups are frequently used when multiple statements need to be used when the syntax permits only one statement to be used. The whole group of statements between the DO and the END are seen as a single statement. This frequently happens with conditional statements such as the IF or SELECT statements.

Iterative DO group

DO (iteration expression list) ;
Zero or more statements;
END ;

DO WHILE group

DO WHILE (condition expression) ;
Zero or more statements;
END ;

DO UNTIL group

DO UNTIL (condition expression) ;
Zero or more statements;
END ;

DO OVER array

DO OVER arrayname ;
Zero or more statements;
END ;

DO OVER usage

The use of DO OVER is no longer documented. An iterative DO group is recommended as better programming practice as the code then explicity states how the array is processed.

See also