heirish lee
heirish lee

Reputation: 29

SAS9.3 PROC FCMP can not save user defined function

I want to use proc fcmp to define my own function in SAS9.3. OS is aix 64bit. Here is my code (reg_func.sas):

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

but after run sas reg_func.sas, i got some warnings

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.

Can anyone help?Thanks!

Upvotes: 1

Views: 1006

Answers (1)

heirish lee
heirish lee

Reputation: 29

Solved! Referrring to https://communities.sas.com/t5/Base-SAS-Programming/Irritating-warning-in-Proc-FCMP/td-p/16216
The key is the cmplib option, here is my code:

    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;

Upvotes: 1

Related Questions