全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2136 4
2015-02-12

66.The following SAS program issubmitted:

data WORK.SALES;

    do Year=1 to 5;

       do Month=1 to 12;

           X + 1;

       end;

    end;

run;

How many observations are written to theWORK.SALES data set?

    A. 0

     B. 1

    C. 5

    D. 60


  

The SAS System

  

        

Obs

         

Year

         

Month

         

X

     
      

1

      

6

      

13

      

60

想问下各位大神,为什么是6 13呢?不应该是5 12 吗?X+1 跟year month有什么关系吗?

谢谢大家!!!


二维码

扫码加我 拉你入群

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

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

全部回复
2015-2-12 23:49:18
所有语言中循环都是一样的吧
二维码

扫码加我 拉你入群

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

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

2015-2-13 06:45:22
At the end of the loop, the index for year will be added 1 to be out of loop, so it will be 6. Think of " do Year=1 to 5;" as something like "year+1;do while year<=5; ". Similar scenario for month.

x+1 will be processed if it is in the loop, so it will be 60 (5 years x 12 months = 60 times) at the end.
二维码

扫码加我 拉你入群

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

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

2015-2-13 08:51:08
因为循环里面无output语句,在循环过程中不向数据集输出,在循环结束时,PDV里只有一条记录,最终数据集里也只有一条记录
二维码

扫码加我 拉你入群

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

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

2015-2-13 19:36:33
kunkunred 发表于 2015-2-13 06:45
At the end of the loop, the index for year will be added 1 to be out of loop, so it will be 6. Think ...
Thx! Very clear!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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