FCMP Procedure

Example 5: Using Variable Arguments with an Array

Details

The following example shows an array that accepts variable arguments. The example implies that the summation function can be called as follows: sum = summation(1,2,3,4,5);

Program

options cmplib=sasuser.funcs;

proc fcmp outlib=sasuser.funcs.temp;
function summation (b[*]) varargs;
    total = 0;
    do i = 1 to dim(b);
        total = total + b[i];
    end;
return(total);
endsub;
sum=summation(1,2,3,4,5);
   put sum=;
run;