Hi, this is my first time using the proc optmodel function and I am wondering if anyone could kindly help me with it.
I am trying to solve for a and b that minimize Npv = (o1-i1)/(1+f1+m1*b+a) + (o2-i2)/((1+f1+m1*b+a)*(1+f2+m2*b+a)).
o1 and o2 are the first two columns of out.
i1 and i2 are the first two columns of in.
f1 and f2 are the first two columns of rf.
m1 and m2 are the first two columns of rm.
Below is my code so far and I have no idea about the correct code for the minimization problem.
Proc Optmodel;
Set<String> Property;
Set Ouf = 1..5;
Set Inf = 1..5;
Set Rfr = 1..5;
Set Mkt = 1..5;
Number out {Property,ouf};
Number in {Property,inf};
Number rf {Property,rfr};
Number rm {Property,mkt};
Read Data Tst3 Into Property=[Prop] {o in ouf}<Out[Prop,o]=col("o"||o)>;
Read Data Tst3 Into Property=[Prop] {i in inf}<In [Prop,i]=col("i"||i)>;
Read Data Tst3 Into Property=[Prop] {f in inf}<Rf [Prop,f]=col("f"||f)>;
Read Data Tst3 Into Property=[Prop] {m in inf}<Rm [Prop,m]=col("m"||m)>;
Var a,b;
Quit;
I tried the code below but that's apparently wrong. I would really appreciate your help.
Min Npv = (Out[o]-In[i])/(1+rf[f]+rm[m]*b+a);
The numeric parameters out, in, rf, and rm all require two arguments. I suspect that you want the following:
Min Npv =
sum {p in Property} (
sum {k in 1..2} (
(out[p,k]-in[p,k])/(prod {j in 1..k} (1+rf[p,j]+rm[p,j]*b+a))
)
)
;
Also note that you can get by with one READ DATA statement:
Read Data Tst3 Into Property=[Prop]
{o in ouf}<Out[Prop,o]=col("o"||o)>
{i in inf}<In [Prop,i]=col("i"||i)>
{f in inf}<Rf [Prop,f]=col("f"||f)>
{m in inf}<Rm [Prop,m]=col("m"||m)>;
The numeric parameters out, in, rf, and rm all require two arguments. I suspect that you want the following:
Min Npv =
sum {p in Property} (
sum {k in 1..2} (
(out[p,k]-in[p,k])/(prod {j in 1..k} (1+rf[p,j]+rm[p,j]*b+a))
)
)
;
Also note that you can get by with one READ DATA statement:
Read Data Tst3 Into Property=[Prop]
{o in ouf}<Out[Prop,o]=col("o"||o)>
{i in inf}<In [Prop,i]=col("i"||i)>
{f in inf}<Rf [Prop,f]=col("f"||f)>
{m in inf}<Rm [Prop,m]=col("m"||m)>;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.