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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

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

Posted 08-20-2019 10:14 AM
(804 views)

Hello,

Is it possible to save in a dataset the solution status of proc optmodel?

I'm indeed running thousands of optimization problems such as:

```
%let byvar = grp;
proc optmodel printlevel=0;
set OBS;
set <str> ASSETS;
set <num,str> GROUPS_ASSETS;
set GROUPS;
num grp{OBS};
num MVC{GROUPS_ASSETS, ASSETS};
num E{GROUPS_ASSETS};
num target_var{GROUPS};
read data MVC into ASSETS=[Name];
read data MVC into OBS=[_N_] grp;
read data MVC nomiss into GROUPS_ASSETS=[k=grp i=Name] {j in ASSETS} <MVC[k,i,j]=col(j)>;
read data Predicted nomiss into [k=grp] {j in ASSETS} <E[k,j]=col(j)>;
read data Target_Var into GROUPS=[grp] target_var;
set BYSET = setof {i in OBS} &byvar.[i];
num by;
set OBS_BY = {i in OBS: &byvar.[i] = by};
set Assets_BY = setof {o in OBS_BY, <(grp[o]),a> in GROUPS_ASSETS} a;
var W{Assets} >= 0;
maximize Expected = sum{i in Assets_BY}W[i]*E[by,i];
con sum{i in Assets_BY, j in Assets_BY}W[i]*MVC[by,i,j]*W[j] = target_var[by];
con BUDGET: sum{i in Assets_BY}W[i] = 1;
num W_sol {GROUPS_ASSETS};
do by = BYSET;
put by=;
solve with NLP / feastol = 1E-7 logfreq = 0 maxiter = 10000;
for {i in Assets_BY} W_sol[by,i] = W[i].sol;
end;
create data Weights_NoShort from [&byvar i] W=W_sol;
quit;
```

However, I noticed that in a few cases, the NOTE in the log is not "Optimal" but:

- NOTE: Maximum number of iterations reached

- NOTE: Infeasible

Saving them in a dataset would allow me to quickly check which *by group* did not solve correctly.

Thank you in advance,

1 ACCEPTED SOLUTION

Accepted Solutions

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

Yes, you can use the _solution_status_ parameter:

```
num W_sol {GROUPS_ASSETS};
str solstatus {BYSET};
do by = BYSET;
put by=;
solve with NLP / feastol = 1E-7 logfreq = 0 maxiter = 10000;
for {i in Assets_BY} W_sol[by,i] = W[i].sol;
solstatus[by] = _solution_status_;
end;
create data Weights_NoShort from [&byvar i] W=W_sol;
create data solstatusdata from [&byvar] solstatus;
```

2 REPLIES 2

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

Yes, you can use the _solution_status_ parameter:

```
num W_sol {GROUPS_ASSETS};
str solstatus {BYSET};
do by = BYSET;
put by=;
solve with NLP / feastol = 1E-7 logfreq = 0 maxiter = 10000;
for {i in Assets_BY} W_sol[by,i] = W[i].sol;
solstatus[by] = _solution_status_;
end;
create data Weights_NoShort from [&byvar i] W=W_sol;
create data solstatusdata from [&byvar] solstatus;
```

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

It's working perfectly, thank you!

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer.

** **

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.