楼主: 水色青空
2460 2

请教几道SAS BASE题(50题),请大家踊跃回答谢谢! [推广有奖]

  • 0关注
  • 0粉丝

大专生

31%

还不是VIP/贵宾

-

威望
0
论坛币
799 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
553 点
帖子
29
精华
0
在线时间
51 小时
注册时间
2009-10-25
最后登录
2024-3-15

楼主
水色青空 发表于 2016-7-9 05:51:49 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
19.A raw data file is listed below.
1---+----10---+----20---+--- 1901 2
1905 1
1910 6
1925 1 1941 1
The following SAS program is submitted and references the raw data file above:
data money;
infile 'file-specification'; input year quantity; total=total+quantity;
run;
What is the value of total when the data step finishes executing?
a. 0
b. 1
c. 11
d. .(missingnumericvalue)

Correct answer: d



47.The following SAS program is submitted: data work.travel;
   do i=1 to 6 by 2;
      trip + i;
end;
run;
Which one of the following is the value of the variable trip in the output data set?
a. 2
b. 3
c. 9
d. 10
Correct answer: c

The sum variable in a sum statement is automatically set to 0 before the first observation is read from the data set. The sum variable in the statement above is increased by the value of i on each iteration of the DO loop; the value of i is set to 1 on the first iteration of the DO loop and increases by 2 on each additional iteration until it is greater than 6. Therefore, the value ofTripis equal to 0 + 1 + 3 + 5, which is 9.

不是应该i=1,3,5吗?那个9 是怎么算出来的?
二维码

扫码加我 拉你入群

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

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

关键词:SAS base Base observation References Additional following before

沙发
cindy2468 发表于 2016-7-10 22:50:48
19. total=total+quantity实际上用了一个赋值语句assign statement,这个语句对数据没有reatin的功能,SAS会将所有变量设成缺失值。
如果你把这个赋值语句:total=total+quantity改为一个sum statement, 即 total+quantity,那么你就会得到你想要的结果11。这里的sum statement起到了非常大的作用:(1)有retain功能 (2)产生新的变量,此处为total (3)在每个观测上+quantity
如果你还是要用total=total+quantity, 则加一个retain total 0 你还是能得到结果11。你可以自己在系统中跑一遍

47. trip=trip+i=0+1+3+5=9这道题其实和刚才的19一样

藤椅
水色青空 发表于 2016-7-11 22:55:11
cindy2468 发表于 2016-7-10 22:50
19. total=total+quantity实际上用了一个赋值语句assign statement,这个语句对数据没有reatin的功能,SAS会 ...
谢谢回复!

明白了!

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-5 19:39