为什么结束括号没有关闭我的 %nrstr 函数?
Why is end parenthesis not closing my %nrstr function?
我的目标是将百分比符号传递到字符串中。
当我 运行:
时,%put 没有结果
%let foo = %nrstr(bar%x%);
%put foo is &foo;
如果再次运行,我得到错误,第一个是
WARNING: The quoted string currently being processed has become more
than 262 bytes long. You might have unbalanced quotation marks."
在企业指南中,括号匹配器不检测右括号。
再添加一个右括号:
%let foo = %nrstr(bar%x%));
结果:
foo is bar%x)
%nrstr 会将不平衡的括号传递到结果中,所以这不足为奇。这似乎意味着只有左括号和右括号的代码段是平衡的。
右括号前的百分比符号导致意外行为。
根据 SAS(R) 9.2 Macro Language: Reference:
percent sign before a parenthesis - for example, %( or %)
two percent signs (%%):
EXAMPLE: %let x=%str(20%%);
编写正确的代码:
%let foo = %nrstr(bar%x%%);
%put foo is &foo;
导致:
foo is bar%x%
我的目标是将百分比符号传递到字符串中。
当我 运行:
时,%put 没有结果%let foo = %nrstr(bar%x%);
%put foo is &foo;
如果再次运行,我得到错误,第一个是
WARNING: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks."
在企业指南中,括号匹配器不检测右括号。
再添加一个右括号:
%let foo = %nrstr(bar%x%));
结果:
foo is bar%x)
%nrstr 会将不平衡的括号传递到结果中,所以这不足为奇。这似乎意味着只有左括号和右括号的代码段是平衡的。
右括号前的百分比符号导致意外行为。
根据 SAS(R) 9.2 Macro Language: Reference:
percent sign before a parenthesis - for example, %( or %) two percent signs (%%): EXAMPLE: %let x=%str(20%%);
编写正确的代码:
%let foo = %nrstr(bar%x%%);
%put foo is &foo;
导致:
foo is bar%x%