Revision: 63832
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 11, 2013 09:01 by webonomic
Initial Code
/* This macro will allow you to step through the lowercase letters of */ /* the alphabet on a %DO loop. For uppercase letters, edit the first */ /* %LET statement to include them as well. */ %macro iterm(beg,end); %let lst=a b c d e f g h i j k l m n o p q r s t u v w x y z; %let start=%sysfunc(indexc(%sysfunc(compress(&lst)),&beg)); %let finish=%sysfunc(indexc(%sysfunc(compress(&lst)),&end)); %do i = &start %to &finish; %put %scan(&lst,&i); %end; %mend; /* Just pass in starting and ending value */ %iterm(a,e) /** An alternative to the above example using the RANK and BYTE function **/ %macro iterm(beg,end); %do i = %sysfunc(rank(&beg)) %to %sysfunc(rank(&end)); %put %sysfunc(byte(&i)); %end; %mend; /* Just pass in starting and ending value */ %iterm(a,e)
Initial URL
http://support.sas.com/kb/25/961.html
Initial Description
This sample contains 2 macro techniques for iterating through character values on a macro %DO loop.
Initial Title
Using character values on a macro %DO loop
Initial Tags
list
Initial Language
SAS