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-18-2020 08:31 AM
(847 views)

Hi all,

I am building a formula which shows below by referring Sum a series in SAS

When I run,

```
start Sumcon(n);
i = 1:n; /* index of terms */
return( sum((deltak/k[i]##2)#exp(r[i]#T[i])#Q[i]) ); /* sum of terms */
finish;
n = T(1:68);
sum = j(nrow(n),1); /* allocate a vector for the results */
do k = 1 to nrow(n);
sum[k] = Sumcon( n[k] );
end;
```

It returns ERROR: (execution) Matrix has not been set to a value.

where the variables k, r, t, Q are all (68,1) vectors, the deltak is a fixed value 5.

How can I achieve this formula?

Thanks a lot.

1 ACCEPTED SOLUTION

Accepted Solutions

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

Here is how I would compute the sum. I am using 5-dimensional vectors instead of 68 elements:

```
proc iml;
/* Use n = 5 instead of 68.
Make up some fake values for the column vectors k, r, t, Q */
k = {1,2,3,4,5};
r = {1,2,3,4,5} / 5;
T = {1,2,3,4,5} / 10;
Q = {1,2,3,4,5} / 15;
deltak = 2;
v = deltak/k##2 # exp(r#T)#Q;
sum = sum(v);
```

7 REPLIES 7

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

ERROR: (execution) Matrix has not been set to a value.

Print out each of the matrices involved and see which one(s) do not have values.

--

Paige Miller

Paige Miller

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

Thanks for replying. However, every column is valued. Is it caused by incorrect use of the sum function?

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

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

Here is how I would compute the sum. I am using 5-dimensional vectors instead of 68 elements:

```
proc iml;
/* Use n = 5 instead of 68.
Make up some fake values for the column vectors k, r, t, Q */
k = {1,2,3,4,5};
r = {1,2,3,4,5} / 5;
T = {1,2,3,4,5} / 10;
Q = {1,2,3,4,5} / 15;
deltak = 2;
v = deltak/k##2 # exp(r#T)#Q;
sum = sum(v);
```

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

Why r, t, Q should divide by 5, 10, 15 respectively? how can I express this when read all var?

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

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

The comment in my program says "Make up some fake values for the column vectors k, r, t, Q"

Thus, these are fake values. Not real. Made up. Use your values instead.

SAS is headed **back** 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.

**Interested in speaking?** Content from our attendees is one of the reasons that makes SAS Innovate such a special event!

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.