data test;
array test{3} $ test1-test3;
input id test1-test3 $;
do i=1 to dim(test);
put i=;
if test(i)='E' then test(i)='F';
end;
cards;
1 A B E
2 E F C
3 C D A
4 A B A
5 B E E
;
run;
do loop 默认每个loop条件执行完i加1,i=3任务结束时,i自动加到了4.如果在end前加一个put语句,就发现i=4,不符合loop条件了,所以循环结束。
data test;
array test{3} $ test1-test3 by 1;
input id test1-test3 $;
do i=1 to dim(test);
put i=;
if test(i)='E' then test(i)='F';
end;
put 'end' i=;
cards;
1 A B E
2 E F C
3 C D A
4 A B A
5 B E E
;
run;