## Macro variable - Urgent Help

Occasional Contributor
Posts: 19

# Macro variable - Urgent Help

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..
Occasional Contributor
Posts: 19

## Re: Macro variable - Urgent Help

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 ;
Occasional Contributor
Posts: 19

## Re: Macro variable - Urgent Help

Can't put all the sas code!
Occasional Contributor
Posts: 19

## Re: Macro variable - Urgent Help

Chris@NewZealand
and
Daniel Santos

Super Contributor
Posts: 474

## Re: Macro variable - Urgent Help

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.
Super Contributor
Posts: 3,176

## Re: Macro variable - Urgent Help

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.
Discussion stats
• 5 replies
• 192 views
• 0 likes
• 3 in conversation