title: SAS User-Defined Function with Optional Parameters
body: <p>Is there a way to create a user-defined function using <code>PROC FCMP</code> that allows optional parameters?</p>
  
  <p>For example, I've written a simple udf in SAS that checks if a string is numeric or not. </p>
  
  <pre><code>PROC FCMP OUTLIB = fcns.functions.all; 
     FUNCTION isNumeric(string $);
        result = ifn(verify(string, " -0123456789") = 0, 1, 0);
        RETURN(result);
     ENDSUB;
  QUIT;
  </code></pre>
  
  <p>Now I would like to check for symbols often associated with numbers, such as <code>$</code>, <code>,</code>, and <code>.</code>, but only if the user specifies. Something like this:</p>
  
  <pre><code>PROC FCMP OUTLIB = fcns.functions.all; 
     FUNCTION isNumeric(string $, symbols=0);
  
        IF symbols = 0 THEN
           result = ifn(verify(string, " -0123456789") = 0, 1, 0);
        ELSE
           result = ifn(verify(string, " -0123456789$,.") = 0, 1, 0);
  
        RETURN(result);
     ENDSUB;
  QUIT;
  </code></pre>
  
  <p>Running the above code gives an error. I've searched online, but haven't been able to find anything on it. Are optional parameters even possible? If they're not, would it be better to create one function with two required parameters, or two separate functions? I lean toward having one function, but thought I'd open up the question.</p>