全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1876 2
2011-05-15
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;

在这段程序中,test有3个元素,i的值最大为3,为什么最后在test数据集中I的值为4???
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-5-15 21:33:52
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;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-5-16 12:42:55
2# sas_user

额,明白了!谢谢啊!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群