SAS9.3 PROC FCMP无法保存用户定义的功能

时间:2016-04-27 03:19:17

标签: sas proc fcmp

我想使用proc fcmp在SAS9.3中定义自己的函数。 操作系统是aix 64bit。 这是我的代码(reg_func.sas):

proc fcmp outlib=mylib.funcs.rule;
function gen_sub_rule();
put "this is a test function";
return (0);
endsub;
run;
quit;

但是在运行sas reg_func.sas之后,我收到了一些警告

WARNING:Cannot wirte model to data set mylib.funcs because it is curently opened or already exists as a standart data set.Will revert to V8 CATALOG instread. WARNING:Failed to save function gen_sub_rule to mylib.funcs.rule.

有人可以帮忙吗?谢谢!

1 个答案:

答案 0 :(得分:1)

解决!引用https://communities.sas.com/t5/Base-SAS-Programming/Irritating-warning-in-Proc-FCMP/td-p/16216
关键是cmplib选项,这是我的代码:

    libname mylib 'H:\saslib\testlib';
    proc fcmp outlib=mylib.funcs.rule;
      function calc(var);
         newvar=log(var);
         return(newvar);
      endsub;
     function gen_str(var1 $, var2 $, var3 $) $100;
        length newvar $100;
        newvar=catx('#', var1, var2, var3);
        return(newvar);
      endsub;
    Run;

    /*list the source code*/
    Options cmplib=_null_; 
    proc fcmp library=mylib.funcs;
      listfunc calc gen_str;
      run;
    Quit;

    /*using func*/
    options cmplib=mylib.funcs; 
      data _null_;
        numret=calc(20);
       charret=gen_str('what', 'is', 'your');
       put numret= charret=;
    run;

    /*delete the func*/
    options cmplib=mylib.funcs; 
    proc fcmp outlib=mylib.funcs.rule;
    deletefunc calc;
    run;
    quit;