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 07-17-2019 03:20 PM
(428 views)

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

- Tags:
- optmodel

1 ACCEPTED SOLUTION

Accepted Solutions

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

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

1 REPLY 1

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

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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.