Friday, August 19, 2011

use %scan function to cycle through a list of items


There are many examples on line.  But I have difficulty to break from the loop following them in one SAS system.


%local count;
%let count=0;


%local cutlist;
%let cutlist =1 5 11 27 44 95 92 82 122 end;
%local curr_cut;

%do %while("%qscan(&cutlist,&count+1,%str( ))" ne "end");
    %let curr_cut = %qscan(&cutlist,&count+1,%str( ));
    %if 0 < &curr_cut %then %additional_function(&curr_cut);    
    %let count = %eval(&count+1);
%end;

No comments: