1
votes

I've just learned PROC FCMP from this page:

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003181727.htm

The function works fine locally, so I wonder if I can use this proc remotely. In my point of view, as long as I change the output library for this function, it could be used in remote server. Here's my code:

proc fcmp outlib=rwork.funcs.trial;
   function study_day2(intervention_date, event_date);
      n = event_date - intervention_date;
         if n >= 0 then
            n = n + 1;
         return (n);
   endsub;
options cmplib=rwork.funcs;
run;

rsubmit;
data _null_;
   start = '15Feb2008'd;
   today = '27Mar2008'd;
   sd = study_day2(start, today);
   put sd=;
run;
endrsubmit;

For the 1st section, I get a notice that the function has been saved in the RWORK library:

NOTE: Function study_day2 saved to rwork.funcs.trial.

However after running the 2nd section, I get this error:

ERROR 68-185: The function STUDY_DAY2 is unknown, or cannot be accessed.

Is there a way to fix this issue? Thanks!

1

1 Answers

0
votes

Assuming you want to program this way (compile the function on your local machine and run it remotely), and you have a machine connected over SAS/CONNECT that is the same operating system and bitness (64/32 bit) as your local machine, you need to run options cmplib=rwork.funcs; in your rsubmit (except you likely need to change it, assuming rwork refers to your remote work directory, to options cmplib=work.funcs;).

rsubmit;
 options cmplib=work.funcs;
 data _null_;
    start = '15Feb2008'd;
    today = '27Mar2008'd;
    sd = study_day2(start, today);
    put sd=;
 run;
endrsubmit;

That option isn't for proc fcmp, as you seem to think based on where you located it. It is telling SAS where to look when using the function. (The outlib option in proc fcmp is what is needed to store it there.)

If your remote server is a different OS or bitness than your local machine, you can't do this, and would need to put the entire section of code in the rsubmit.