全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1473 5
2011-07-15
原题如下:我不懂为啥答案是D,能否解释一下, 谢谢
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: D
我运行了一段相似的代码, 显示drop statement有误,
391 data work.january;
392 set sasuser.sales (keep=lastname month Residential Commercial);
393 if month='JAN' then output work.january;
394 sales=Residential+Commercial;
395 (drop=residential commercial);
-
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
396 format sales dollar12.2;
397 run;
二维码

扫码加我 拉你入群

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

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

全部回复
2011-7-15 05:50:43
他是想这样的把drop放在开头:
data WORK.JANUARY (drop=Month  Quantity  Cost);
而不是在最后

我也在学base,哈哈
二维码

扫码加我 拉你入群

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

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

2011-7-15 07:13:35
Drop= 和 keep= 属于data set option, 应该放在数据集名字后面的括号里。



data class(Keep=name weight);
       set sashelp.class;
run;

data class(drop=age sex height);
      set sashelp.class;
run;

Drop 和 keep 语句要作为data step中独立的一句,后面不能跟等号。

data class;
      set sashelp.class;
     keep name weight;
run;

data class;
    set sashelp.class;
   drop age sex height;
run;
二维码

扫码加我 拉你入群

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

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

2011-7-15 08:24:41
谢谢回复
根据line 109  in the SAS log ,
此题的答案应是
drop Month  Quantity  Cost;
无括号和等号, 原题是不是没有答案?
二维码

扫码加我 拉你入群

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

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

2011-7-15 08:28:07
看懂原题了,答案是D
二维码

扫码加我 拉你入群

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

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

2011-7-15 09:47:41
data set option--------------->(drop=Month  Quantity  Cost)
DROP statement------------>drop Month  Quantity  Cost
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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