| www.sas.com > SAS UK > In the Know Homepage | Search | Contact Us |
|
|
|
|
The following macro can be used to increment a loop by non-continuous numeric values, character values, or both; supplied as a parameters to the macro. The macro works by using a do while loop to scan the supplied list of values for the nth “word” (or number) that it finds and assigns this “word” to a macro variable. The macro variable “i” will be available to the code that we need to execute. At the bottom of the loop we increment “j” by one so that we can scan for the next “word” in the string and so on. The loop will stop executing as soon as the scan returns a blank value. In this simple example we are using the technique in order to print selected members of a library.
%macro test(lib,values);
|