<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849036#M335684</link>
    <description>&lt;P&gt;The PROC FCMP in your example is running on the SAS client. I suspect you want the functions available on the CAS server so that you can call it from, for example, a DATA step running in CAS or the dataStep.runCode action. See the example in the FCMP action set ("fcmpact"):&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_031/caspg/p08cbowc5u7okdn15wp2hmuuwrk4.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/v_031/caspg/p08cbowc5u7okdn15wp2hmuuwrk4.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Dec 2022 00:29:38 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-12-12T00:29:38Z</dc:date>
    <item>
      <title>How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849019#M335683</link>
      <description>&lt;P&gt;Hi SAS Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm working on extending SAS Packages Framework (&lt;A href="https://github.com/yabwon/SAS_PACKAGES" target="_blank"&gt;https://github.com/yabwon/SAS_PACKAGES&lt;/A&gt;) with new type: "CASLUDF" i.e., CAS-L user defined functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;During the process the following question arose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets assume I have this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib = work.f.p;
  function fcmpFunction(x);
    return(x*10);
  endsub;
run;

options cmplib=work.f;

data _null_;
  x = 17;
  y = fcmpFunction(x);
  put "x=" x  "y=" y;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so I have valid and working FCMP function to "solve my programming challenges".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to create new CAS-L user defined function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
  /* insert code here */

  function CASLfunction(x);
    RETURN( fcmpFunction(x) + 1) ; /* &amp;lt;- here I want to use the FCMP function */
  end func;

  x = 17;
  y = CASLfunction(x);
  print "x=" x  "y=" y;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The question is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How can I modify above Proc CAS code (if it is possible at all) to use the FCMP function inside a CAS-L user defined function&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it documented some where?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I read the doc. about the "FCMP Action Set" but it seems to be doing job "in other way round", like: create FCMP function from within Proc CAS and store it inside a data set. For further use in data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 22:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849019#M335683</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-12-11T22:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849036#M335684</link>
      <description>&lt;P&gt;The PROC FCMP in your example is running on the SAS client. I suspect you want the functions available on the CAS server so that you can call it from, for example, a DATA step running in CAS or the dataStep.runCode action. See the example in the FCMP action set ("fcmpact"):&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_031/caspg/p08cbowc5u7okdn15wp2hmuuwrk4.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/v_031/caspg/p08cbowc5u7okdn15wp2hmuuwrk4.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 00:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849036#M335684</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-12T00:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849061#M335700</link>
      <description>&lt;P&gt;Hi Rick (&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;) Thanks for the link! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I read that one already and it is not what I'm looking for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My case is: I already have a dataset with FCMP functions. Question is how can I use those functions inside Proc CAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second thing is that it looks like the doc. page is for latest release and not for Viya 3.5. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When I executed this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sascas1 cas caslib=casuser;

proc cas;
 loadactionset "fcmpact";

 setSessOpt{cmplib="casuser.f"}; 
run; 

source BS_code; /**/

 function fcmpFunction(x);
  return(x*10);
 endfunc;

endsource;

fcmpact.addRoutines / 
 saveTable = true, 
 funcTable = {name="f", caslib="casuser", replace=true}, 
 package = "myPackage", 
 routineCode = BS_code; 
run;
quit;


options fullstimer msglevel=I;
options cmplib=sascas1.f;

data sascas1.class;
 set sashelp.class(obs=2);
run;

data _null_;
 set sascas1.class;
 x = 17;
 y = fcmpFunction(x);
 put "x=" x "y=" y;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All steps except the last one run successfully (including note: "&lt;SPAN&gt;NOTE: Cloud Analytic Services saved the file F.sashdat in caslib CASUSER&lt;/SPAN&gt;"), but the last data step gave:&lt;/P&gt;
&lt;PRE&gt;115  data _null_;
116    set sascas1.class;
117    x = 17;
118    y = fcmpFunction(x);
NOTE:  The where clause is being processed by Cloud Analytic Services.
NOTE:  The where clause is being processed by Cloud Analytic Services.
NOTE: No CMP or C functions found in library sascas1.f.
118    y = fcmpFunction(x);
           ------------
           68
ERROR 68-185: The function FCMPFUNCTION is unknown, or cannot be accessed.
119    put "x=" x  "y=" y;
120  run;
NOTE: The SAS System stopped processing this step because of errors.&lt;/PRE&gt;
&lt;P&gt;There is also a big chance that I'm doing something wrong. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 10:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849061#M335700</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-12-12T10:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849119#M335722</link>
      <description>&lt;P&gt;I can verify that your program works in Viya 4. I do not have Viya 3.5, so someone else will have to assist you.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 15:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/849119#M335722</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-12T15:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/871044#M344060</link>
      <description>&lt;P&gt;Hi Bart&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;running Viya 3.5 I get exactly the same error.&lt;/P&gt;
&lt;P&gt;There's a problem note but the fix does not work for me either.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/kb/62/620.html" target="_self"&gt;https://support.sas.com/kb/62/620.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What DOES work is to use the sas code within a cas fcmpact.runProgramm block.&lt;/P&gt;
&lt;P&gt;In a data step it keeps giving error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
cas mySession sessopts=(caslib="casuser");
data casuser.cars;
set sashelp.cars;
run;

proc cas; 

table.fetch / table={name="cars" caslib="casuser"} to=5; 
run;

sessionProp.setSessOpt / cmplib="CASUSER.MULTIPLICATION ";
run;
fcmpact.addRoutines /
   routineCode = "
     function times2( a );
       return(a*2);
     endsub;

     function times10( a );
       return(a*10);
     endsub;

     function times3( a );
       return(a*3);
     endsub;"
   package = "pkg"
   saveTable = true
   funcTable = {name="multiplication" replace=true};
run;
fcmpact.runProgram /  
   routineCode = "
     length make_and_model varchar(*);
     hp2 = times10(horsepower);                 /* Add a numeric variable. */
     mpg_highway = hp2 + times3(mpg_highway);  /* Replace a numeric variable. */
     make_and_model = make || ', ' || model;   /* Add a varchar variable. */
    "
  inputData={name="cars"}
  outputData={name="cars_modified" replace=true};
run;

table.fetch / 
   table="cars_modified" 
   fetchVars={"make_and_model", "horsepower", "hp2", "mpg_highway"}
    to=5;
run;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2023 08:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/871044#M344060</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-04-21T08:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/900913#M356042</link>
      <description>&lt;P&gt;I wrote a blog about doing it. Here is the blog and code:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2023/10/30/create-user-defined-functions-udfs-for-the-cas-server-on-sas-viya/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2023/10/30/create-user-defined-functions-udfs-for-the-cas-server-on-sas-viya/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 13:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/900913#M356042</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2023-10-31T13:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: How (if posssible) to use FCMP functions inside CAS-L user defined functions?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/901626#M356310</link>
      <description>&lt;P&gt;Hi Peter! (&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152214"&gt;@Panagiotis&lt;/a&gt;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the link, very interesting article. I enjoyed reading and learned something new.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately it still does not answers my question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my question I had a SAS dataset generated by FCMP as an input rather than "text of a function code" (like in your "source" statement).&lt;/P&gt;
&lt;P&gt;But I guess I can do a workaround myself by&amp;nbsp;creating a new text variable which concatenates (as a text string) the "Value" variable&amp;nbsp; from the FCMP's dataset and push the result then to the actionSet, right ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2023 18:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-if-posssible-to-use-FCMP-functions-inside-CAS-L-user-defined/m-p/901626#M356310</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-05T18:17:48Z</dc:date>
    </item>
  </channel>
</rss>

