楼主: hailingkatherin
1880 4

SAS Base do loop 问题 [推广有奖]

  • 0关注
  • 0粉丝

硕士生

82%

还不是VIP/贵宾

-

威望
0
论坛币
277 个
通用积分
0
学术水平
1 点
热心指数
5 点
信用等级
1 点
经验
164 点
帖子
126
精华
0
在线时间
87 小时
注册时间
2015-1-18
最后登录
2016-5-15

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

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有什么关系吗?

谢谢大家!!!


二维码

扫码加我 拉你入群

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

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

关键词:SAS base Base loop observations observation following written

沙发
teqel 发表于 2015-2-12 23:49:18 |只看作者 |坛友微信交流群
所有语言中循环都是一样的吧

使用道具

藤椅
kunkunred 发表于 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.
已有 1 人评分论坛币 收起 理由
admin_kefu + 50 热心帮助其他会员

总评分: 论坛币 + 50   查看全部评分

使用道具

板凳
wpfwxn 发表于 2015-2-13 08:51:08 |只看作者 |坛友微信交流群
因为循环里面无output语句,在循环过程中不向数据集输出,在循环结束时,PDV里只有一条记录,最终数据集里也只有一条记录

使用道具

报纸
hailingkatherin 发表于 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!

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 12:32