2

Is it possible to specify a default value for proc fcmp function parameters? Something like this:

proc fcmp outlib=work.funcs.funcs;

  function my_func(param1, param2='default_value_here' $);
    * DO STUFF;
  endsub;

run;

From the documentation and the error messages I'm receiving, I'm not seeing anything that would indicate that it is supported but it seems like it would be a big oversight if that is the case.

SAS 9.4TSM4

Robert Penridge
  • 8,424
  • 2
  • 34
  • 55

1 Answers1

2

It's not possible in the way you describe (as in, obviously, you could emulate a default by applying equivalent logic in the function itself). The thing is, if there was a default, it could not be invoked..

You see, proc fcmp does not support 'optional' arguments (except the VARARGS array). So you would always have to supply a value (which could include missing or a null reference), hence the default would never be applied.

If this ever comes up in a SASware ballot, it gets my vote - optional arguments should definitely be an option in fcmp!

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
  • 3
    FCMP unfortunately has a lot of limitations, born out of the fact that it was initially something added to the language to support certain procedures, and only later added to the data step, never really intended to be a first class method of writing code as far as I can tell. Sigh. IIRC the person who was the driving force behind it moved onto other projects after a few years and FCMP never really got enough backing to become first class- perhaps because the hope was DS2 would replace it (don't get me started about _that_...) Unfortunately the macro language still wins for functions. – Joe Nov 20 '17 at 22:36