缺少 SAS proc fcmp returns

SAS proc fcmp returns missing

我有以下代码:

options mprint mlogic symbolgen;
%macro get_vtype();
  %let table = %sysfunc(dequote(&table.));
  %let var = %sysfunc(dequote(&var.));

  data metadata.temp;
    set &table.;
    var = vtype(&var.);
    call symput('res',vtype(&var.));
  run;
%put &=res;
%mend;
proc fcmp outlib=work.functions.wrapper;
  function myvtype(table $,var $) $ 1;
    rc = run_macro('get_vtype',table,var,res);
    put rc;
    put res;
    return (res);
  endsub;
quit;
options cmplib=work.functions;
data temp;
  vtype = myvtype("sashelp.class","age");
run;

我希望得到 N 作为临时结果。然而它不见了。在调试时我提到,%put &=res; 解析为 N,但 put res;returns.`。 问题是什么?

我的猜测是 metadata 库没有在 run_macro 会话中分配。

我用 run_macro 得到了一些非常奇怪和不一致的结果,我会尽可能避免它 - 试试 dosubl。以下代码有效:

%macro get_vtype(table,var);
  data _null_;
    set &table.;
    var = vtype(&var.);
    call symputx('res',vtype(&var.),'g');
    stop;
  run;
%put &=res;
%mend;
proc fcmp outlib=work.functions.wrapper;
  function myvtype(table $,var $) $ 1;
    rc = dosubl(cats('%get_vtype(',table,',',var,');'));
    put rc;
    length res ;
    res=symget("res");
    put res;
    return (res);
  endsub;
quit;
options cmplib=work.functions;
data test;
  vtype = myvtype("sashelp.class","age");
run;