BookmarkSubscribeRSS Feed
1234567
Calcite | Level 5
Proc optmodel run 20 different optimizations and results were saved in sas dataset. I want to save c1 and c2 from the previous results as a macro variable and then pass them back to PROC OPTMODEL for the next optimization. So by doing this the previous results of c1 and c2 will be used as starting values for the next run. Thanks..
5 REPLIES 5
1234567
Calcite | Level 5
proc optmodel ;
var c1 init - 3 >= - 3 <= 2.93;
var c2 init - 3 >= - 3 <= 8.86;
number a; set R= 1..20; number aval{i in R} = i/20; number c1val{i in R}, c2val{i in R}, c3val{i in R}; number sensval{i in R};
max Sensitivity = 1-probbnrm((c1-1.43)/.5,(c2-2.86)/2, 0);
con FPF: 1-probbnrm((c1-0)/1,(c2-0)/1, 0) <= a;
for {i in R} do;
a = aval;
solve with IPNLP / MAXTIME=14400 MAXITER=100000 printfreq = 0 ;
c1val = c1;
c2val = c2;
sensval = Sensitivity;
end;
create data mrocBP from FPR=aval c1=c1val c2=c2val MTPR=sensval ;
quit ;
1234567
Calcite | Level 5
Can't put all the sas code!
1234567
Calcite | Level 5
Chris@NewZealand
and
Daniel Santos

Please your help
DanielSantos
Barite | Level 11
Hello.

I'm not sure I got this right...

You just need to call proc optmodel several times (at leas 2 times) feeding the output of the previous iterations (CREATE DATA OUT) to the input of the next (READ DATA IN). Is this right?

How is your code structured? Are we talking about a single script?
And is it a single call to the optmodel procedure per script, or is it possible to have more than one call in same script?

Finally, how many iterations do need?

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
An intermediate DATA step using CALL SYMPUT will allow you to capture a SAS variable value and place it in a SAS global/local macro variable, for later use. If you are working with a macro and a %DO / %END loop, you can declare the macro variable up-front using %LOCAL or %GLOBAL, and then use an %IF %THEN testing the %LENGTH() to determine the first execution and then don't do something on the first DO loop execution (there are also other techniques as well).

Scott Barry
SBBWorks, Inc.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1169 views
  • 0 likes
  • 3 in conversation