Hi,
Not sure where to post this (recommendations welcome), but be aware of a bug in SAS when using proc fcmp functions in proc sql - the variable scopes are not resolved correctly and assignments to arguments within the fcmp functions are actually made to the arguments that are passed (despite a warning in the log stating that they're not). Here's a minimal reproducible example:
proc fcmp outlib=work.functions.mre;
function get_a_value(arg $);
arg = "FromFcmp";
return(0);
endsub;
run;
option CMPLIB=work.functions;
proc sql;
create table example as select x, get_a_value(x) as y from (select "From Sql" as x from dictionary.libnames);
quit;
Interesting thing, wonder wether it is FCMP's problem or SQL's ?
Because (what is "funny") in the datastep it works ok.
proc fcmp outlib=work.functions.mre;
function get_a_value(arg $);
put "BEFORE: inside FCMP" arg ;
arg = "FromFcmp";
put "AFTER: inside FCMP" arg ;
return(lengthn(arg));
endsub;
run;
option CMPLIB=work.functions;
data example2;
x = "From Sql";
put _ALL_;
y=get_a_value(x);
put _ALL_;
run;
[EDIT:] I would go to SAS Tech. Support with that.
Bart
Contacting tech support is recommended, as it looks like either a very fancy feature or a bug.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.