BookmarkSubscribeRSS Feed

When running below code more than once in a session I'm getting a warning that I can't suppress.

proc fcmp outlib=work.funcs.demo;
  function demo(in);
    out=in+1;
    return (out);
  endsub;
run;

option CMPLIB=work.funcs;
data _null_;
  xx=demo(5);
run;
WARNING: Function 'demo' was defined in a previous package. Function 'demo' as defined in the current program will be used as 
         default when the package is not specified.

What I would like as an extension to PROC FCMP are two new options:
NOWARN:  Suppress above warning and write a NOTE instead.

NOREPLACE: To not replace the already compiled function. Write a NOTE that the function already exists and won't be replaced.

3 Comments
yabwon
Onyx | Level 15

Hi Patrick,

 

Try this:

option CMPLIB=_null_; /* Add this to fix the problem */
proc fcmp outlib=work.funcs.demo;
   ...
run;
option CMPLIB=work.funcs;

The _null_ will fix the problem.

 

Of course if the CMPLIB list is longer (contains several elements)  you will have to put a bit more effort:

/* for example your CMPLIB is */
option CMPLIB=(work.A work.B work.C);



%let tmp_CMPLIB = %sysfunc(getoption(CMPLIB)); /* get and save the list */
%put &=tmp_CMPLIB.;
option CMPLIB=_null_; /* clean the list */

proc fcmp outlib=work.funcs.demo;
  function demo(in);
    out=in+1;
    return (out);
  endsub;
run;

options CMPLIB=&tmp_CMPLIB.; /* restore the list */

option append=(CMPLIB=work.funcs); /* append new element */

data _null_;
  xx=demo(5);
run;

 

 

Patrick
Opal | Level 21

@yabwon A workaround for the "Warning issue". Thanks.

sean_mealin
SAS Employee
Status changed to: Suggestion Under Review

The suggestion is under review, but I don't think it is something that we will be able to implement for a while.