SAS Optimization, and SAS Simulation Studio

turn on suggestions

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

Showing results for

Find a Community

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-08-2016 12:00 PM - edited 12-09-2016 02:40 PM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-08-2016 04:24 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-09-2016 09:29 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-09-2016 01:43 PM

Can you please show your Profit macro?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-09-2016 02:32 PM - edited 12-09-2016 02:37 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-12-2016 02:14 PM

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.