全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3151 2
2008-04-18

56. The following SAS program is submitted:

%let a = cat;

%macro animal (a=frog);

%let a = bird;

%mend;

%animal (a=pig)

%put a is &a

 

Which one of the following is written to the SAS log?

 

  1. a is &a

  1. a is cat

  1. a is pig

  1. a is bird

Correct answer: b

 

Q30. the following SAS program is submitted:

%let a=apple;

%macro fruit;

%let a = orange;

%mend;

%fruit

%put a is &a;

 

Which one of the following is written to the SAS log?

 

  1. a is apple

  2. a is orange

  3. a is &a

  4. a is

Correct answer: b

请大家帮我看看这两道题的区别。谢谢。

二维码

扫码加我 拉你入群

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

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

全部回复
2008-4-18 13:15:00

56.  程序先建一个gloabl 的变量a, 赋值cat;然后运行macro程序,建一个local macro 变量a ,赋值frog,因为最终调用了这个程序,所以local a 的值最终是pig.但是local macro 变量只在macro 程序中有效,所以macro 程序调用完之后,local a 会从local symbol table 中删除,所以最终只有global table中的a,她的值就是cat

30. 和56不同,在complie macro 程序的时候,当读到%let a = orange;的时候,程序先到local symbol table 中去找local a,但是没有这个local变量;然后去global table 中去找,找到了有global macro a.所以就将它的值改成orange.

[此贴子已经被作者于2008-4-18 13:15:43编辑过]

二维码

扫码加我 拉你入群

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

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

2008-4-21 12:52:00
十分感谢。
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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