I define the following temporary function in some code that's run on a monthly basis.
proc fcmp outlib=work.funcs.mi5152;
function fTerm(interm);
if interm < &num_months. then return (&num_months. - 1);
else return (interm);
endsub;
run;
options cmplib=work.funcs;
I use this function in the rest of the program, and finally delete it.
proc fcmp outlib=work.funcs.mi5152;
deletefunc fTerm;
run;
This all works fine the first time I run it, but if I run the same code a second time (e.g. in the event of a rerun) in the same session, I get the following warning.
WARNING: No CMP or C functions found in library work.funcs.
Any ideas what this warning means and how I can get rid of it? I've found that, if i omit the deletefunc step, the warning merely says that the function has already been defined, which is slightly less perplexing.
You can avoid this warning, I believe if to redefine your cmplib option after you perform the deletefunc step. Then rebuild the function and reassign cmplib.
Thanks FriedEgg, I tried doing this but I still get the same error.
proc fcmp outlib=work.funcs.mi5152; function foo(bar); return(1); endsub; run; options cmplib=work.funcs; proc fcmp outlib=work.funcs.mi5152; deletefunc foo; run; options cmplib=work.funcs;
If I run the above code twice, I get the warning on the second occasion.
Here's another way of coding it and avoiding both types of irritating Proc FCMP warning messages (i.e. "No CMP or C functions found in library work.funcs" and "Function fTerm is already defined...") when running it multiple times in the same session:
%macro compfunc(num_months=);
%let funcexists=n;
data _null_;
%if %sysfunc(exist(work.funcs)) %then %do;
set work.funcs(where=(type eq 'Prototype' and lowcase(name) eq "mi5152"));
call symput('funcexists',"y");
stop;
%end;
run;
%if &funcexists eq n %then %do;
proc fcmp outlib=work.funcs.mi5152;
function fTerm(interm);
if interm < &num_months. then return (&num_months. - 1);
else return (interm);
endsub;
run;
options cmplib=work.funcs;
%end;
%mend compfunc;
%compfunc(num_months=??);
Yes, CMP library management definitely needs upgrading. My limited experience led me to these workarounds :
/* Repeat this */
proc fcmp outlib=work.funcs.mi5152;
function foo(bar);
return(1);
endsub;
run;
options cmplib=work.funcs;
/* Use the function */
proc fcmp outlib=work.funcs.mi5152;
deletefunc foo;
run;
options cmplib=();
or leave a dummy function in the library as in :
/* Run only once */
proc fcmp outlib=work.funcs.mi5152;
function Dum(bar);
return(1);
endsub;
run;
/* Repeat this */
proc fcmp outlib=work.funcs.mi5152;
function foo(bar);
return(1);
endsub;
run;
options cmplib=work.funcs;
/* Use the function */
proc fcmp outlib=work.funcs.mi5152;
deletefunc foo;
run;
PG
I couldn't get either suggested solution to work for me.
I started playing about with the data sets, the options and the FCMP itself and still couldn't get it to work. However, i noticed that the message didn't come up when I started a new SAS session, only during subsequent runs - even after I deleted the data set.
This made me think that resetting the CMPLIB option to () wasn't resetting SAS to the default, it was just setting it to "()"
I did find that setting the option to:
options cmplib = _null_;
before the FCMP seemed to stop the message appearing.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.