BookmarkSubscribeRSS Feed
TomCook
Calcite | Level 5

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.

5 REPLIES 5
FriedEgg
SAS Employee

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.

TomCook
Calcite | Level 5

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.

ColinDun
Calcite | Level 5

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=??);

PGStats
Opal | Level 21

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

PG
nevla
Fluorite | Level 6

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 6899 views
  • 6 likes
  • 5 in conversation