[英]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
.` 哇是問題?
我的猜測是,在run_macro
會話中沒有分配metadata
數據庫。
我在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 $1;
res=symget("res");
put res;
return (res);
endsub;
quit;
options cmplib=work.functions;
data test;
vtype = myvtype("sashelp.class","age");
run;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.