【问题标题】:SAS simple Macro - ErrorSAS 简单宏 - 错误
【发布时间】:2014-09-30 11:27:06
【问题描述】:

为什么这么简单的宏程序:

%macro test1(N=,NN=);
proc iml;
start fun_test(x) global(&NN,&N);
x=&NN+&N;
finish fun_test;
call fun_test(x);
print x;
run;
quit;
%mend test1;
%test1(N=10,NN=22);

给出错误? :

      22
ERROR 22-322: Expecting a name.
ERROR 200-322: The symbol is not recognized and will be ignored.

【问题讨论】:

  • 实际上,它给出了正确的答案,但这个错误仍然存​​在
  • 不应该更像:%macro test1(N,NN); proc iml; start fun_test(x) global(&NN,&N); x=&NN+&N; finish fun_test; call fun_test(x); print x; run; quit; %mend test1; %test1(10,22);
  • 谢谢@jj72uk 但我仍然有同样的错误
  • 我们还可以添加:Options symbolgen;在调用宏之前

标签: macros sas sas-iml


【解决方案1】:

START 语句中的 GLOBAL 子句需要有效 SAS 标识符的名称。当您调用宏时,程序解析为

   start fun_test(x) global(22,11);
    ...

这是无效的语法。

也许这就是你要找的东西?

%macro test1(N=,NN=);
proc iml;
start fun_test(x) global(N,NN);
x=N + NN;
finish fun_test;
N = &N; NN = &NN;
call fun_test(x);
print x;
run;
quit;
%mend test1;
%test1(N=10,NN=22);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多