z*******e 发帖数: 32 | 1 被两道题搞得头晕,请路过的大侠指点,跪谢!
1. The following SAS program is submitted:
%let Mv=shoes;
%macro PRODUCT(Mv=bicycles);
%let Mv=clothes;
%mend;
%PRODUCT(Mv=tents)
%put Mv is &Mv;
What is written to the SAS log?
A.Mv is bicycles
B.Mv is clothes
C.Mv is shoes
D.Mv is tents
这道题答案是C,理由是local macro variable在macro结束以后就被清空了,global
macro variable的值shoes还在,所以要用global的。
2. The following SAS program is submitted:
%let a=cat;
%macro animal;
%let a=dog;
%mend;
%animal
%put a is &a;
Which one of the following is written to the SAS log?
Correct answer: d
a. a is
b. a is &a
c. a is cat
d. a is dog
如果照第一道题的解释,岂不是要选C。怎么这道题又变成了选D? |
Z********6 发帖数: 10 | 2 1.
%let Mv=shoes; *here Mv is a global macro variable;
%macro PRODUCT(Mv=bicycles); *here Mv is a local macro variable;
%let Mv=clothes; *here Mv is a local macro variable;
%mend;
%PRODUCT(Mv=tents);
%put Mv is &Mv; * => Mv is shoes;
2.
%let Mv=shoes; *here Mv is a global macro variable;
%macro PRODUCT;
%let Mv=clothes; *here Mv is a global macro variable;
%mend;
%PRODUCT; *replace previous Mv value;
%put Mv is &Mv; * => Mv is clothes;
Hope this will help you to see the difference and know why. |
z*******e 发帖数: 32 | 3 This is really helpful! Appreciated it...
是不是可以这样理解,一个macro variable是global还是local,跟这个variable是否
是在macro里面被defined是没关系的? |
L**********A 发帖数: 7115 | 4 http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML
【在 z*******e 的大作中提到】 : This is really helpful! Appreciated it... : 是不是可以这样理解,一个macro variable是global还是local,跟这个variable是否 : 是在macro里面被defined是没关系的?
|
z*******e 发帖数: 32 | |