Others have suggested that you use PROC FCMP, which is not a bad idea if your code is that complicated. But you can also do it as a function-style macro, if you are trying something relatively simple, e.g.: %macro CS_factor(index);
ChooseN(&index,
1,
0.99999882161769,
0.99999882161769,
0.99999080089355,
0.99996111096086,
0.99988122640202,
.... rest of values go here
)
%mend;
data test;
do cs=1 to 23;
cs_score=%cs_factor(cs);
output;
end;
run; Note that I did not put a final semicolon in the expression inside the macro; that way, the macro can be used just as you would use a normal function call, e.g. "CS_plustwo=%cs_factor(cs)+2;". Note that the CHOOSEN function truncates the index value, and reports an error if the index is out of range. Which may be OK with you, else you may have to modify the function call, e.g.: %macro CS_factor(index);
ChooseN(ifn(1<=&index<=23,&index,24),
1,
0.99999882161769,
0.99999882161769,
0.99999080089355,
0.99996111096086,
0.99988122640202,
.... rest of values go here
. /* missing value for index out of range */
) %mend;
... View more