The following SAS program is submitted:
%let sun=SHINE;
%let shine=MOON;
proc print data=weather(keep=sun shine moon);
sum &&&&sun;
run;
Which one of the following variables is summed in the resulting report?
Correct answer: c
a. sun
b. MOON
c. SHINE
d. None, an ERROR message will be written to the log.
选C,解释是When the macro processor encounters multiple ampersands preceding a macro variable
reference, it resolves two ampersands into one ampersand and re-scans the reference. In this
example, the macro processor resolves the reference &&&&sun to &&sun on the first scan. Then,
the macro processor re-scans and resolves the reference to &sun, and re-scans again, finally
resolving the reference to SHINE.
在sas里跑了一下,2,4,8,16个的时候 结果是Shine,3,5,6,9,10个&的时候结果是moon。7或者14个& 的时候结果是&moon 请问为什么只有7 是不同的呢?怎么解析的呢?