这是可能将具有宏触发器的字符串作为宏参数传递吗? 请参阅下面的示例代码:SAS MACRO引用问题:将具有宏触发器的字符串作为宏参数传递
options mprint;
%let string5='%abc%def%';
%macro test(string);
data _null_;
call execute('%test2('||&string.||')');
run;
%mend;
%macro test2(string2);
data test3;
a=%str(%')&string2.%str(%');
run;
%mend;
%test(&string5);
此代码成功运行,但它试图调用宏%ABC和DEF%,这导致了警告。
如果我试图把它变成引用掩盖的字符串,它给了语法错误,如下图所示:
options mprint;
%let string5='%abc%def%';
%macro test(string);
data _null_;
call execute('%test2('||%superQ(string)||')');
run;
%mend;
%macro test2(string2);
data test3;
a=%str(%')&string2.%str(%');
run;
%mend;
%test(&string5);
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, arrayname, (, +, -, INPUT, NOT, PUT, ^, _NEW_, ~.
有没有办法解决这个问题,而不警告? 在此先感谢!
你究竟在做什么?这可能是一个更简单的方法。 – user667489
我试图通过类似的模式作为参数,其中包含%。我在这里做的只是一个例子。 –
当通过CALL EXECUTE调用宏时,使用'%nrstr()'非常有用,但我不确定这对您的问题是否有影响。 '调用执行(猫'('%nrstr(%test2)(',symget('string'),')');' – Tom