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 06-16-2020 05:44 AM
(864 views)

When I run the code following

```
proc iml;
start main;
varNames = {"tau" "K" "call_option_price" "S" "r" "put_option_price" "T" };
use cboe; * use the import data set;
read all var varNames;
```

T = tau/365;
F = K + exp(r*T) * (call_option_price - put_option_price);
K0 = int(F);
finish;

It returns

ERROR: (execution) Matrices do not conform to the operation.

where

operation : * at line 89 column 14

operands : r, T

r 2531 rows 1 col (numeric)

T 2531 rows 1 col (numeric)

I know the calculations should be conducted between matched matrixes. However, I found the variable r and T have the same structure with 2531 rows and 1 col.

1 ACCEPTED SOLUTION

Accepted Solutions

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

5 REPLIES 5

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

You have read in column vectors. There are two ways to multiply with column vectors: the inner product and elementwise multiplication. An inner product will return a scalar. Elementwise multiplication will return a vector.

The asterisk (*) is used for matrix and vector operations. So r`*T will return the inner product. The # operator performs elementwise multiplication. So r#T will return a vector.

If you are trying to perform the same operation on each row of the data, then the syntax is

`F = K + exp(r#T) # (call_option_price - put_option_price);`

By the way, you can delete the lines "start main;" and "finish." You might have inserted them because you have a RUN statement at the end of the program. A RUN statement is not necessary.

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

It works. However, when I use this method to run the following syntax, it returns ERROR: Invocation of unresolved module SQR.

`sigma = sqr(2/T # sum(deltak/K) # exp(R # T) # Q-1/T # (F/K0-1) ## 2);`

where deltak is an Integer 5 and all the other variables are read in iml as elementwise I think. Is it caused by the incorrect use of sum function? The parameter k is a vector with n rows and 1 column.

how can I achieve Summation[i] (deltak[i]/k[i]) correctly?

Thanks.

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

The ERROR message tells you the problem: There is no SQR function. Did you mean SQRT for "square root"?

The SUM function looks correct.

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

Yes it is. I have changed it to sqrt().

But why it returns following error when I perform sqrt() for this calculation.

ERROR: (execution) Invalid argument to function.

count : number of occurrences is 1437

operation : SQRT at line 93 column 13

operands : sigma_2

sigma_2 2531 rows 1 col (numeric)

If I remove the sqrt() function, it works well.

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

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

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.