FWIW, a separate SAS discussion forum exists for the SAS/IML product. For what you have described in your post (to some extent), there are two different SAS programming techniques, each with their own purpose to do_over/iterate - mentioned below:
DATA step language:
DO I=0 TO 4;
* your SAS DATA step code goes here. ;
END;
MACRO language:
%DO I=0 %TO 4;
%* your SAS macro code goes here. ;
%END;
Suggest you start with some basic SAS system reading and go from there - links to SAS support
http://support.sas.com/ website documentation and technical / conference paper references below.
Scott Barry
SBBWorks, Inc.
SAS-hosted DOCUMENTATION references:
SAS(R) 9.2 Language Reference: Concepts, DATA Step Processing:
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001281588.htm
Step-by-Step Programming with Base SAS(R) Software - Introduction to DATA Step Processing
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001302699.htm
SAS Macro Language: Reference
Introduction to the Macro Facility
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293969.htm
SAS Language Reference by Name, Product, and Category - Macro Statements Syntax Sorted Alphabetically
http://support.sas.com/documentation/cdl/en/allprodslang/62304/HTML/default/syntaxByType-macroStatem...
SAS SQL Procedure User's Guide - Introduction to the SQL Procedure
http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a002536894.htm
CONFERENCE PAPER references:
A Hands-On Introduction to SAS® DATA Step Programming
Debbie Buck, D. B. & P. Associates, Houston, TX (a SUGI conference paper)
http://www2.sas.com/proceedings/sugi30/134-30.pdf
Understanding the SAS® DATA Step and the Program Data Vector
Steven First, Systems Seminar Consultants, Madison, WI
http://support.sas.com/resources/papers/proceedings09/136-2009.pdf
SAS Macro Programming for Beginners
Susan J. Slaughter, Avocet Solutions, Davis, CA
Lora D. Delwiche, Delwiche Consulting, Winters, CA
http://www2.sas.com/proceedings/sugi29/243-29.pdf