I am new to proc fcmp
and I want to know how to write a user-defined function with varying amount parameters, which like whichc()
or coalesce()
, in SAS.
I will be grateful if anybody could give me some hints.
It's not possible, although you can pass arrays as described here (reproduced below):
function sas_summation (b[*]) varargs;
total = 0;
do i = 1 to dim(b);
total = total + b[i];
end;
return(total);
endsub;
run;
quit;
options cmplib=work.functions;
data one;
input x1-x5;
datalines;
1 2 3 4 5
2 3 4 5 6
4 5 6 7 8
;
run;
data two;
set one;
array temp (5) _temporary_;
array perm2 (*) x1-x5;
do i=1 to dim(temp);
temp(i)=perm2(i);
end;
drop i;
x=sas_summation(temp);
run;