Your new_variable is being reset at every iteration of the loop, so it will only show a value of 1 if Reason_Code_10 begins with 'RR'. The solution from solves this problem, another option is to put an UNTIL statement in the do loop so that it stops processing when 'RR' is encountered do i=1 to 10 until (R_indicator{i}=:'RR'); Yet another possibility, if the letters 'RR' only occur at the start of the string (or you want to search for them anywhere in the string), is to drop the array completely and use the INDEX and CATX functions together. new_variable=index(catx(',',of Reason_Code:),'RR')>0;
... View more