请选择 进入手机版 | 继续访问电脑版
楼主: meihuangsibs
2319 3

SAS70题之25,运行结果出乎意料 [推广有奖]

  • 0关注
  • 0粉丝

高中生

50%

还不是VIP/贵宾

-

威望
0
论坛币
702 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
431 点
帖子
11
精华
0
在线时间
42 小时
注册时间
2014-6-15
最后登录
2021-8-26

meihuangsibs 发表于 2016-10-15 04:22:20 |显示全部楼层 |坛友微信交流群
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
SAS base 70题的第25题

Given the following code:

procprint data=SASHELP.CLASS(firstobs=5 obs=15);

   where Sex='M';

run;

How many observations will be displayed?

     A.11

     B.15

     C.10 or fewer

     D.11 or fewer


直观理解是从obs5开始读到obs15, 所以答案是D, 但是我运行了一下,结果如下


Untitled.png

有没有哪位前辈也实际运行过这个代码,这个问题在哪里呢?


二维码

扫码加我 拉你入群

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

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

关键词:出乎意料 observations observation following observat following where

meihuangsibs 发表于 2016-10-15 04:24:57 |显示全部楼层 |坛友微信交流群
重新传下图片
Untitled.png

使用道具

DriftKingHan 发表于 2016-10-15 16:16:29 |显示全部楼层 |坛友微信交流群
运行下面的对比一下,就知道了
  1. proc print data=SASHELP.CLASS;
  2.         where Sex='M';
  3. run;
复制代码


下面是SAS文档的话,也就是先where再obs=,obs=也不是对数据集的obs而言的
(我的理解是,firstobs=和obs=都是最后执行的,在最终的输出上的位置)
Note that with WHERE processing, SAS first subsets the data and applies OBS= to the subset.
If you apply FIRSTOBS=2 and OBS=10 to the subset, then the result is nine observations, that is (10 - 2) + 1 = 9. OBS= in this situation is neither the observation number to end with nor how many observations to process; the value is used in the formula to determine when to stop processing.

使用道具

meihuangsibs 发表于 2016-10-19 01:19:06 |显示全部楼层 |坛友微信交流群
DriftKingHan 发表于 2016-10-15 16:16
运行下面的对比一下,就知道了
谢谢楼上大侠解答,如果不用option, 那么结果中还有1,5,6,9四个obs符合sex=‘M',所以firstobs=5就指向obs10了,非常感谢。

使用道具

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

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

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

GMT+8, 2024-4-19 02:39