5 个&的output是 two
基本规则是:
1.系统把2个&变成一个,前面四个& 变成 & &
2. 剩下&test 变成 one
到此系统得到的变量是 &&one
重复上面的步骤:
1. 将两个&变成一个,得到&one
所以最后结果是&one=two
从上面的分析可以看出 2n个&和n个&的效果是一样的 用这个小技巧做题的时候可以简化很多
根据这些规则楼主可以验证:
若有1,2,4,8,。。。个&,输出为one
3,5,6,9 。。。个&, 输出为two
7个&,输出为three
一下为SAS网站上找到的一个例子:
%put &&city&n; /* correct */
If &N contains 6, when the macro processor receives this statement, it performs the following steps:
1.resolves && to &
2.passes CITY as text
3.resolves &N into 6
4.returns to the beginning of the macro variable reference, &CITY6, starts resolving from the beginning again, and prints the value of CITY6