请选择 进入手机版 | 继续访问电脑版
楼主: Amandanannn
3159 5

[问答] SAS Advance 130题中第80题 [推广有奖]

  • 0关注
  • 1粉丝

本科生

6%

还不是VIP/贵宾

-

威望
0
论坛币
3 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
16704 点
帖子
40
精华
0
在线时间
79 小时
注册时间
2015-12-12
最后登录
2018-7-13

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
求各位大神帮我看一下下面这道题:

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

Answer: A

我想,它的运行顺序及宏变量的定义形式应该是: %let rc=Begin; ------Global
                                                                       %let rc=Before Execution; ------Global
                                                                       %test; (在这里rc会被赋值成high或low) ------Local
因为SASHELP.PRDSALE有50条observation,带到程序中后,50>10,那么%let rc = high,但是为什么答案会是A(low)呢??

十分不解,在此请各位大侠帮忙答疑解惑![em49] 多谢多谢!![em44]
二维码

扫码加我 拉你入群

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

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

关键词:ADVANCE advan VANCE ance Van execution following

50>10%let rc = high为local宏变量
global中&rc的值是宏编译时生成的%let rc=low

使用道具

谢谢您的回复! 可是,依然不是很明白,“50>10%let rc = high为local宏变量”——这个没问题,可是,“global中&rc的值是宏编译时生成的%let rc=low”——这个就不懂了!  %macro test难道不是local吗? 还有,当50>10的时候,运行到%let rc=high的时候不就终止了吗??
多谢多谢![em49]

使用道具

hftz3326 学生认证  发表于 2017-1-27 16:25:43 |显示全部楼层 |坛友微信交流群
Amandanannn 发表于 2016-3-3 22:42
谢谢您的回复! 可是,依然不是很明白,“50>10%let rc = high为local宏变量”——这个没问题,可是,“glo ...
我来告诉你,这题你没注意的是if不是%if哦,else也是,所以执行时是忽略他们的,所以rc不断地被赋值Global,从begin-high-low揪出来了

使用道具

wanqingyin7 学生认证  发表于 2018-7-10 03:34:18 |显示全部楼层 |坛友微信交流群
hftz3326 发表于 2017-1-27 16:25
我来告诉你,这题你没注意的是if不是%if哦,else也是,所以执行时是忽略他们的,所以rc不断地被赋值Globa ...
一语道破~ 谢谢!

使用道具

loria99 发表于 2018-11-26 01:23:12 |显示全部楼层 |坛友微信交流群
hftz3326 发表于 2017-1-27 16:25
我来告诉你,这题你没注意的是if不是%if哦,else也是,所以执行时是忽略他们的,所以rc不断地被赋值Globa ...
我也在这道题上纠结了很久。。。万分感谢~~~~我又把%put放到不同位置试了一下,分享我run的结果...

3286  %let rc = Begin;
3287  %put the value of RC at the begining is &rc;
the value of RC at the begining is Begin

3288  %macro test;
3289  data out;
3290  set sashelp.prdsale nobs = totalobs;
3291  if totalobs > 10 then do;
3292  %let rc = high;
3293  end;
3294  %put the value of RC in marco before else do is &rc;
3295  else do;
3296  %let rc = low;
3297  end;
3298  run;
3299  %put the value of RC in marco before mend is &rc;
3300  %mend;
3301  %put the value of RC after mend is &rc;
the value of RC after mend is Begin

3302
3303  %let rc = Before Execution;
3304
3305  %put the value of RC before call is &rc;
the value of RC before call is Before Execution

3306  %test
the value of RC in marco before else do is high

NOTE: There were 1440 observations read from the data set SASHELP.PRDSALE.
NOTE: The data set WORK.OUT has 1440 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds


the value of RC in marco before mend is low3307  %put the value of RC after call is &rc;
the value of RC after call is low


使用道具

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

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

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

GMT+8, 2024-4-16 14:40