Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 12-08-2016 12:00 PM
(1240 views)

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.

`rsubmit;`

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;

endrsubmit;

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

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

$,peak,Num_comp_periods,Num_pay_period_year,Discount_rate,Free_Appr_cost,Amex_Point_Cost,cash_back_cost);

rc = run_macro('Profit',V5YC, F1YC, F2YC, F3YC, F4YC,

F5YC,seg,peak,Num_comp_periods,Num_pay_period_year,Discount_rate,Free_Appr_cost,Amex_Point_Cost,cash_back_cost,Sum_profit2,NII2,Vol2);

if rc eq 0 then return(Sum_profit2);

else return(.);

endsub;

endrsubmit;

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

function.

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.

Thanks,

Farshid

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

attachments. -##

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

$,peak,Num_comp_periods,Num_pay_period_year,Discount_rate,Free_Appr_cost,Amex_Point_Cost,cash_back_cost);

rc = run_macro('Profit',V5YC, F1YC, F2YC, F3YC, F4YC,

F5YC,seg,peak,Num_comp_periods,Num_pay_period_year,Discount_rate,Free_Appr_cost,Amex_Point_Cost,cash_back_cost,Sum_profit2,NII2,Vol2);

if rc eq 0 then return(Sum_profit2);

else return(.);

endsub;

endrsubmit;

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

function.

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.

Thanks,

Farshid

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

attachments. -##

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Can you please show your Profit macro?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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; .... quit; proc sql; .... quit; proc sql; .... quit; proc sql; .... quit; proc sql; .... quit; /*Summarize the costs*/ proc sql; .... quit; /*application costs*/ proc sql; .... quit; data APP_COST; ... run; /*Out_Profit*/ /*%let mydataid=%sysfunc(open(Out_Profit, i));*/ data _NULL_; %GLOBAL SUM_PROFIT2; set OUT_PROFIT; call SYMPUT('SUM_PROFIT2',sum_profit); run; %let result = &SUM_PROFIT2; %MEND Profit;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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. **

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.