楼主: les_islander
4089 3

[原创博文] 求问两道70的题,关于keep与drop option和等号、括号 [推广有奖]

  • 0关注
  • 0粉丝

初中生

14%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
147 点
帖子
16
精华
0
在线时间
8 小时
注册时间
2008-2-23
最后登录
2014-5-5

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
正在对着crackman的70题复习,有两题相比较,有所不解,请求大家帮助答疑解惑,谢谢~!

我的疑问在于,keep和drop的用法规律是一样的吗?如果是,为何第70题答案说如在set中则需要括号与等号,而第6题却要除去等号?

谢谢!

第6题

6.After a SAS program is submitted, the following is written to the SAS log:

  101    data WORK.JANUARY;
  102    set WORK.ALLYEAR(keep=product month num_Sold Cost);
  103    if Month=’Jan’ then output WORK.JANUARY;
  104    Sales=Cost * Num_Sold;
  105    keep=Product Sales;
                        —–
                        22
  ERROR 22-322: Syntax error, expecting one of the following: !,!!, &, *, **, +, -, , <=, <>, =, >, >=,
                AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,NOTIN, OR, ^=, |, ||, ~=.
  106  run;

What changes should be made to the KEEP statement to correct the errors in the LOG?

     A. keep=(Product Sales);
     B. keep Product, Sales;
     C. keep=Product, Sales;
     D. keep Product Sales;

Answer: D
本文属于博客:http://www.crackman.net 版权归作者所有,如有转载,请注明出处!未经本作者同意不得用于商业应用。
其他本博客文章均作此声明!

本道题考察的是KEEP语句的语法问题
在括号内就是KEEP=
如果不是就是KEEP



第70题

70.After a SAS program is submitted, the following is written to the SAS log:

105    data WORK.JANUARY;
106    set WORK.ALLYEAR(keep=Product Month Quantity Cost);
107    if Month='JAN' then output WORK.JANUARY;
108    Sales=Cost * Quantity;
109    drop=Month Quantity Cost;
                      -----
                      22
ERROR 22-322: Syntax error, expecting one of the following: !,
                !!, &, *, **, +, -,
, <=, <>, =, >, >=,
                AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,
                NOTIN, OR, ^=, |, ||, ~=.
110 run;

What data set option could be attached to WORK.JANUARY to replace the DROP statement that generated the error in the log?
     A. (drop Month Quantity Cost)
     B. (drop Month, Quantity, Cost)
     C. (drop=Month, Quantity, Cost)
     D. (drop=Month Quantity Cost)
Answer: A

DROP语句,在DATA STATEMENT中,不需要等号
在SET 语句中,需要括号以及等号。



二维码

扫码加我 拉你入群

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

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

关键词:Option keep drop OPT TIO following product written option

沙发
juneandvictor 发表于 2012-6-28 03:56:56 |只看作者 |坛友微信交流群
" Keep option"
102    set WORK.ALLYEAR(keep=product month num_Sold Cost);


"Keep statement"
D. keep Product Sales;   

使用道具

藤椅
stormhoof 发表于 2012-7-11 15:18:13 |只看作者 |坛友微信交流群
keep和drop用法都一样,比如data WORK.JANUARY(keep=product);和data WORK.JANUARY;keep product;是一样的。第一种处理数据比较效率

使用道具

板凳
星落荒原 发表于 2014-12-10 03:39:35 |只看作者 |坛友微信交流群
楼主你70题答案错了吧,应该选择D。据我所知(keep=)应该用在括号内,而keep不需要()。(keep=)可用在data 和set还有过程中,而keep只可以用在data和set中。同事keep没有(keep=)用效率,因为当(keep=)用在set中时,只读取需要保留的变量,而keep在使用时要读取所有变量
已有 1 人评分论坛币 收起 理由
admin_kefu + 30 热心帮助其他会员

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

使用道具

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

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

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

GMT+8, 2024-4-26 21:10