BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abigailpai
Calcite | Level 5

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);

 

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

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)>;

View solution in original post

1 REPLY 1
RobPratt
SAS Super FREQ

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)>;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 1 reply
  • 1003 views
  • 0 likes
  • 2 in conversation