DATA Step, Macro, Functions and more

Irritating warning in Proc FCMP

Reply
New Contributor
Posts: 3

Irritating warning in Proc FCMP

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.

Trusted Advisor
Posts: 1,300

Irritating warning in Proc FCMP

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.

New Contributor
Posts: 3

Irritating warning in Proc FCMP

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.

N/A
Posts: 1

Re: Irritating warning in Proc FCMP

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

Respected Advisor
Posts: 4,641

Re: Irritating warning in Proc FCMP

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
Learner
Posts: 1

Re: Irritating warning in Proc FCMP

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.

Ask a Question
Discussion stats
  • 5 replies
  • 2127 views
  • 1 like
  • 5 in conversation