/***************************************************************************************************************** SAS file name: function_subroutine.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate the difference between a function and a subroutine in PROC FCMP Author: Peter Clemmensen Creation Date: 15/12/2019 This program supports the blog post "PROC FCMP Function Vs Subroutine in SAS" on SASnrd.com *****************************************************************************************************************/ /* Function */ proc fcmp outlib=work.f.f; subroutine s (in1, in2, out1, out2); outargs out1, out2; out1=in1 + in2; out2=in1 * in2; endsub; run;quit; options cmplib=work.f; data _null_; call s1(2, 3, sum, prod); put sum= / prod=; run; /* Subroutine */ proc fcmp outlib=work.f.f; function f(in1, in2); out=in1 + in2; return (out); endsub; run;quit; options cmplib=work.f; data _null_; s = f(1, 2); put s=; run;