全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1253 6
2015-11-02
悬赏 10 个论坛币 未解决
80. The following SAS program is submitted:
%let rc = Begin;
%macro test;
data out;
set sashelp.prdsale nobs = totalobs;
if totalobs > 10 then do;
%let rc = high;
end;
else do;
%let rc = low;
end;
run;
%mend;
%let rc = Before Execution;
%test
The data set SASHELP.PRDSALE has 50 observations.
What is the value of the variable RC when the macro finishes execution?
A.low
B.high
C.Begin
D.Before Execution


二维码

扫码加我 拉你入群

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

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

全部回复
2015-11-3 00:57:46
I think it Should be D because &RC is got global.

But why don't you run it in sas? You will have a definitive answer. Playing with is the best way to learn it.
----- updated: my previous answer is incorrect. According to sas document, macro variables defined outside of any macro are global. So in this case, the value should be assigned by the last time %let statement is used.

Sorry for the wrong answer.
二维码

扫码加我 拉你入群

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

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

2015-11-3 03:34:10
johnpark1 发表于 2015-11-3 00:57
I think it Should be D because &RC is got global.

But why don't you run it in sas? You will have ...
已经上机跑了,答案是low,就是没想明白为什么是这个。
二维码

扫码加我 拉你入群

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

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

2015-11-3 12:01:34
这里有2个变量RC,一个是global, 一个是local.

在macro结束运行的时侯,local 的 RC是low,但是global 的 RC 是Before Execution。题目问的应该是local RC的值。

”Since local symbol tables exist separately from the global symbol table, it is possible to have a local macro variable and a global macro variable that have the same name and different values.”
二维码

扫码加我 拉你入群

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

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

2015-11-3 12:14:43
mandyfervor 发表于 2015-11-3 03:34
已经上机跑了,答案是low,就是没想明白为什么是这个。
See my correction above.
二维码

扫码加我 拉你入群

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

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

2015-11-4 05:57:48
stayhungry05 发表于 2015-11-3 12:01
这里有2个变量RC,一个是global, 一个是local.

在macro结束运行的时侯,local 的 RC是low,但是global  ...
local的怎么就是low呢? totalobs是50 是大于10的,那也应该是运行第一个也就是rc=high啊。
我在想是不是因为是%let 是定义global变量的,所以不受condition的限制。
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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