BookmarkSubscribeRSS Feed
Fluorite | Level 6

I get the error message when I try to run the following sas code on SAS UNIX server but the code runs without any error on local windows computer. I was wondering if someone know the possible cause for this error.


proc fcmp outlib=work.ds.functions; function Tot_profit(V5YC, ...); rc = run_macro('Profit',...); if rc eq 0 then return(Sum_profit2); else return(.); endsub; run;

options cmplib=work.ds;
proc optmodel;

VAR V5YC init 1, F1YC init 1,F2YC init 0,F3YC init 3.20111035,F4YC init 3.20111035,F5YC init 3.20111035;
MAX Total_profit = Tot_profit( V5YC, ... );

CON A: 3.29>= F3YC >= 2.89;
CON B: 3.89>= F4YC >= 2.39;
CON C: 4.49>= F5YC >= 2.44;

solve with nlp /tech=ip ms msnumstarts=50 msprintlevel=5 printfreq=50 MSDISTTOL=10000;

quit; run;



Community Manager

From the PROC OPTMODEL doc:


Not all PROC FCMP functionality is compatible with PROC OPTMODEL; in particular, the following FCMP functions are not supported and should not be called within your FCMP function definitions: READ_ARRAY, WRITE_ARRAY, RUN_MACRO, and RUN_SASFILE. In many cases, OPTMODEL capabilities can replace these functions. Matrix arguments can be used in place of the READ_ARRAY function by using the READ DATA statement to load the matrix in PROC OPTMODEL. Similarly, you can replace the WRITE_ARRAY function in an FCMP subroutine by copying the matrix to an output argument and using the OPTMODEL procedure to write the matrix. You can use the SUBMIT statement in place of the RUN_MACRO and RUN_SASFILE functions.


That doesn't explain why you find that it works on your local SAS, unless perhaps more support was added in a later version of SAS and that's what you're running locally.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Fluorite | Level 6

Thanks for the response.

As I explained the proc fcmp is working well with proc optmodel on my
Windows PC but the error appears when I run it on UNIX server using
rsubmit. I believe the problem is not generated from proc optmodel but it's
only from the remote submit of proc fcmp since when I run the following
code I get the same error (ERROR: Cannot find a library containing
subroutine RUN_MACRO.).

rsubmit ;
proc fcmp outlib=xwork.ds.functions;

function Tot_profit(V5YC, F1YC, F2YC, F3YC, F4YC, F5YC,seg
rc = run_macro('Profit',V5YC, F1YC, F2YC, F3YC, F4YC,
if rc eq 0 then return(Sum_profit2);
else return(.);


The reason that I'm using proc fcmp (called "Tot_profit") to create a
function which calls a macro function (called "Proft"). The Tot_profit
function is later called from proc optmodel to calculate the objective
function and the input arguments to that function is the optimization
variables and the outcome is the objective value which is supposed to be
maximized. If I just call the macro function directly from the proc
optmodel without utilizing the function created by proc fcmp then I get the
following error message for any line of code I add after calling the macro

ERROR 180-322: Statement is not valid or it is used out of proper order.

So please let me know your thoughts about the first error message from
remote submit of proc fcmp and also if you have any suggestion for calling
a macro function during optimization directly from proc optmodel without
utilizing proc fcmp.


##- Please type your reply above this line. Simple formatting, no
attachments. -##

Can you please show your Profit macro?

Fluorite | Level 6

Unfortunately I can't share the details but it involved several proc sqls and data steps to generate the output profit (SUM_PROFIT2) using the given inputs:



%MACRO Profit(seg=,....);

proc sql;

proc sql;

proc sql;

proc sql;

proc sql;

/*Summarize the costs*/
proc sql;

/*application costs*/
proc sql;

data APP_COST;

/*%let mydataid=%sysfunc(open(Out_Profit, i));*/
data _NULL_;
	call SYMPUT('SUM_PROFIT2',sum_profit);
%let result = &SUM_PROFIT2;
%MEND Profit;


Fluorite | Level 6

I checked the version that I have on my local computer which was 9.03.01M1P110211 for Base SAS and the one that is running on UNIX server: 9.03.01M2P080112 . Although the one that runs on the server is more recent but the library error appears on this version but not the old version on my local.



Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.


Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 


Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 3 in conversation