Hi, I'd like to simplify my function by using only 1 array name so I can avoid to use an 'if then' statement at the end: /*Get Tarif Paramaters*/
proc fcmp outlib=mydata.functions.func;
function Get_Parameter(Product $, Sex,Smoker,Type_Tariff); /* Sex = 1 or 2, Smoker =1 or 2 , Type_Tariff= 1 or 2 */
if Product="A" then
do;
array f[2,2,2] (4 3,
2 1,
8 7,
6 5);
end;
else if Product="B" then
do;
array q[2,2,2] (-4 -3,
-2 -1,
-8 -7,
-6 -5);
end;
if Product="A" then
return ( f[Sex,Smoker,Type_Tariff]);
else if Product="B" then
return ( q[Sex,Smoker,Type_Tariff]);
endsub;
Data paramater;
do product= "A" ,"B";
do Sex=1 to 2;
do Smoker=1 to 2;
do Type_Tariff=1 to 2;
a=Get_Parameter(product,Sex,Smoker,Type_Tariff);
output;
end;
end;
end;
end;
run; This is what I want but it doesn't work because I can't have the same array name for 2 different vectors. /*Get Tarif Paramaters*/
proc fcmp outlib=mydata.functions.func;
function Get_Parameter(Product $, Sex,Smoker,Type_Tariff); /* Sex = 1 or 2, Smoker =1 or 2 , Type_Tariff= 1 or 2 */
if Product="A" then
do;
array f[2,2,2] (4 3,
2 1,
8 7,
6 5);
end;
else if Product="B" then
do;
array f[2,2,2] (-4 -3,
-2 -1,
-8 -7,
-6 -5);
end;
return ( f[Sex,Smoker,Type_Tariff]);
endsub;
Data paramater;
do product= "A" ,"B";
do Sex=1 to 2;
do Smoker=1 to 2;
do Type_Tariff=1 to 2;
a=Get_Parameter(product,Sex,Smoker,Type_Tariff);
output;
end;
end;
end;
end;
run; thank u for ur help
... View more