楼主: kevinye123
3532 5

[问答] Adv 的问题 求救! [推广有奖]

  • 0关注
  • 0粉丝

本科生

79%

还不是VIP/贵宾

-

威望
0
论坛币
20 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
12285 点
帖子
103
精华
0
在线时间
106 小时
注册时间
2012-9-20
最后登录
2017-11-3

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
85. Given the SAS data set OURDATA:
OURDATAObsproduct sales
1 OR 1000
2 NE 1200
3 MM 1450
After submitting a SAS program, the following is written to the SAS log:
70 %macro a;
71 data _null_;
72 set ourdata;
73 call symput('product'!!left(_n_), product);
74 run;
75 %if &product1 = OR %then %do;
76 proc means data = ourdata;
77 run;
78 %end;
79 %mend;
80 %a
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
73:66
NOTE: There were 3 observations read from the data set WORK.OURDATA.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is
required. The condition was: &product1=OR
ERROR: The macro A will stop executing.
Which statement replaces the code in line 75 to successfully complete the program?
A.%if &product1 = %bquote(OR) %then %do;
B.%if %bquote(&product1) = OR %then %do;
C.%if %bquote(&product1 = OR) %then %do;
D.%if %bquote(&product1) = %bquote(OR) %then %do;

答案为什么是D?
当 product1 变成 OR 的时候问什么不能直接用 %if &product1 = OR 而要用 %bquote呢?

谢谢各位了

二维码

扫码加我 拉你入群

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

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

关键词:observations Successfully observation successful statement

沙发
moyunzheng 发表于 2013-7-24 23:46:22 |只看作者 |坛友微信交流群
因为OR是SAS保留的关键字,代表逻辑“或”,所以必须quote
参见:Summary of Macro Quoting Functions and the Characters They Mask

使用道具

藤椅
kevinye123 发表于 2013-7-25 08:06:19 |只看作者 |坛友微信交流群
多谢!

使用道具

板凳
iceiiy 发表于 2015-6-23 11:12:02 |只看作者 |坛友微信交流群
那为什么不能选A

使用道具

iceiiy 发表于 2015-6-23 11:12
那为什么不能选A
因为程序执行时 左边的&product1解析成OR  此时左边的OR是没有经过quoting的 因此sas还是把他当成一个关键词  所以左右的OR都得需要经过bquote的quoting

使用道具

地板
lzcllyt 发表于 2018-2-20 22:34:49 |只看作者 |坛友微信交流群
厉害!!受教了

使用道具

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

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

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

GMT+8, 2024-4-20 05:37