Reputation: 29
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
Can anyone help?Thanks!
Upvotes: 1
Views: 1006
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