The "do over" syntax for arrays

This post was kindly contributed by Ken's SAS tricks - go there to comment and to read the full post.

This is another useful not-a-trick.

No longer to be found in the documentation is the “do over” syntax, which can simplify code and keep datasets narrower.  The syntax works like this:

   data ...;

array arrayname x y z var1 - var3;

do over arrayname;

if arrayname lt 0 then arrayname eq 0;

end;

run;

 

In the example above, all the variables listed after “arrayname” are recoded so that the smallest value is 0.  Note that the array is not explicitly indexed, even with the [*] format.

This post was kindly contributed by Ken's SAS tricks - go there to comment and to read the full post.