我是 proc fcmp
的新手,我想知道如何编写具有不同数量参数的用户定义函数,例如 whichc()
或 SAS 中的 coalesce()
。
如果有人能给我一些提示,我将不胜感激。
最佳答案
这是不可能的,尽管您可以按照描述传递数组 here (转载如下):
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;
关于parameters - 如何定义具有不同数量参数的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55355531/