全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2532 3
2016-10-15
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

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


二维码

扫码加我 拉你入群

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

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

全部回复
2016-10-15 04:24:57
重新传下图片
附件列表
Untitled.png

原图尺寸 23.38 KB

Untitled.png

二维码

扫码加我 拉你入群

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

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

2016-10-15 16:16:29
运行下面的对比一下,就知道了
复制代码


下面是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.
二维码

扫码加我 拉你入群

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

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

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

扫码加我 拉你入群

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

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

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

说点什么

分享

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