Working with SAS Data Sets |
If you try to read past the end of a data set or point to an observation greater than the number of observations in the data set, you create an end-of-file condition. If an end-of-file condition occurs inside a DO DATA iteration group, IML transfers control to the next statement outside the current DO DATA group.
The following example uses a DO DATA loop while reading the CLASS data set. It reads the variable WEIGHT in one observation at a time and accumulates the weights of the students in the IML matrix SUM. When the data are read, the total class weight is stored in the matrix SUM.
setin class point 0; sum=0; do data; read next var{weight}; sum=sum+weight; end; print sum;
Copyright © SAS Institute, Inc. All Rights Reserved.