Hey! I'm new to using Proc FCMP. This is my first attempt. Just experimenting with replacing some repetitive code that's a string of functions with a Proc FCMP function. However, I've run into a little trouble with the VVALUEX function that's in the string I'm trying to replace. Looking for a little help! Using Base SAS 9.4.
Here's an example of the code I'm trying to replace. I realize this may not make sense - just playing around with Proc FCMP.
LALAE_Lmtd_Paid_LDF_PLmt_Upper = Input(Left(VValueX(Catt('LALAE_',PLmt_Upper_LDF_Char,'Pd'))),8.); LO_Lmtd_Incd_LDF_Ded_Lower = Input(Left(VValueX(Catt('LO_',Ded_Lower_LDF_Char,'Inc'))),8.); XS_Incd_LDF_Ded_Lower = Input(Left(VValueX(Catt('XS_',Ded_Lower_XS_LDF_Char,'Inc'))),8.); LALAE_Lmtd_Incd_LDF_100K = Input(Left(VValueX('LALAE_LDF_100kInc')),8.);
Here's the Proc FCMP code and error message:
Proc FCMP Outlib = My_Lib.functions.myfncs; Function MyFctrLkp(Fctr_To_Lkp $); Fctr = Input(Left(VValueX(Fctr_To_Lkp)),8.); Return(Fctr); EndSub; Run;
ERROR: The VVALUEX function is only valid in the DATA step. User defined libraries will be searched for a
definition of this function.
NOTE: Numeric value converted to character for argument 1 of 'LEFT' operation.
ERROR: Cannot find a library containing subroutine VVALUEX.
NOTE: Execution aborted because of errors in program.
Here's what I'm trying to accomplish:
LALAE_Lmtd_Paid_LDF_PLmt_Upper = MyFctrLkp(Catt('LALAE_',PLmt_Upper_LDF_Char,'Pd')); LO_Lmtd_Incd_LDF_Ded_Lower = MyFctrLkp(Catt('LO_',Ded_Lower_LDF_Char,'Inc')); XS_Incd_LDF_Ded_Lower = MyFctrLkp(Catt('XS_',Ded_Lower_XS_LDF_Char,'Inc')); LALAE_Lmtd_Incd_LDF_100K = MyFctrLkp('LALAE_LDF_100kInc');
Thanks!
Variables in the program data vector are not accessible within a function. Consider:
proc fCMP Outlib = work.functions.myfncs;
Function Myfunct();
Fctr = age;
Return(Fctr);
EndSub;
run;
options cmplib=work.functions;
data want;
set sashelp.class;
var=Myfunct();
put var=;
run;
which results in VAR=. for all observations. That's because you have to pass the value of age TO the function in the guise of a function argument (which may or may not also be named age). Of course no message is generated - only missing values.
But VVALUEX is one layer worse, since it is supposed to have variable name as an argument and then go to the pdv to get the value for that variable. The function compiler knows this, so it tells you VVALUEX can't be used within a function definition.
Variables in the program data vector are not accessible within a function. Consider:
proc fCMP Outlib = work.functions.myfncs;
Function Myfunct();
Fctr = age;
Return(Fctr);
EndSub;
run;
options cmplib=work.functions;
data want;
set sashelp.class;
var=Myfunct();
put var=;
run;
which results in VAR=. for all observations. That's because you have to pass the value of age TO the function in the guise of a function argument (which may or may not also be named age). Of course no message is generated - only missing values.
But VVALUEX is one layer worse, since it is supposed to have variable name as an argument and then go to the pdv to get the value for that variable. The function compiler knows this, so it tells you VVALUEX can't be used within a function definition.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.