楼主: mandyfervor
1010 6

[问答] adv 130 中80 多谢 [推广有奖]

  • 0关注
  • 0粉丝

本科生

34%

还不是VIP/贵宾

-

威望
0
论坛币
3271 个
通用积分
0
学术水平
5 点
热心指数
5 点
信用等级
5 点
经验
1378 点
帖子
67
精华
0
在线时间
83 小时
注册时间
2015-8-24
最后登录
2023-9-4

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


关键词:observations observation EXECUTION following observat execution
沙发
johnpark1 发表于 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.
已有 1 人评分论坛币 热心指数 收起 理由
mandyfervor + 1 + 1 热心帮助其他会员

总评分: 论坛币 + 1  热心指数 + 1   查看全部评分

使用道具

藤椅
mandyfervor 发表于 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,就是没想明白为什么是这个。

使用道具

板凳
stayhungry05 发表于 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.”
已有 1 人评分论坛币 热心指数 收起 理由
mandyfervor + 1 + 1 热心帮助其他会员

总评分: 论坛币 + 1  热心指数 + 1   查看全部评分

使用道具

报纸
johnpark1 发表于 2015-11-3 12:14:43 |只看作者 |坛友微信交流群
mandyfervor 发表于 2015-11-3 03:34
已经上机跑了,答案是low,就是没想明白为什么是这个。
See my correction above.
已有 1 人评分论坛币 热心指数 收起 理由
mandyfervor + 1 + 1 那跑出来的结果为什么不是high呢?

总评分: 论坛币 + 1  热心指数 + 1   查看全部评分

使用道具

地板
mandyfervor 发表于 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的限制。

使用道具

mandyfervor 发表于 2015-11-4 05:57
local的怎么就是low呢? totalobs是50 是大于10的,那也应该是运行第一个也就是rc=high啊。
我在想是不是 ...
%let是macro statement 在你的data step 运行之前就已经执行了 data step的逻辑对它没有任何影响

使用道具

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

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

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

GMT+8, 2024-4-24 01:50