Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- 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**.
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 08-19-2023 03:33 PM
(1272 views)

Hi

I keep getting errors regarding variables in my module although these values are well defined. Sometimes SAS gives no error at all and some other times SAS doesn't let it go. It feels like the program is been hunted😊

Can any one help me please figure out where is the problem.

Thank you all

1 ACCEPTED SOLUTION

Accepted Solutions

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

You are redefining L at the bottom of the DO JJ =... loop.

Don't do that. It replaces the previous dimensions of L.

At the end of the loop, I suggest you use Lower and Upper as variable names instead of L and U.

5 REPLIES 5

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

The error message tells you that the problem is on Line 6753, which is the statement **Sum = 1 + R[m];**

The error message also tells you that when the error occurs:

- R is a (1 x 1) matrix with the value 3.
- m is a (1 x 1) matrix with the value 5.

The expression R[5] gives an error because R only has 1 element, not 5 or more. Thus, you get an error that states, "invalid subscript or subscript out of range."

There are several places where you are calling the Adaptive module, and in one of those places you are calling it with invalid parameters.

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

Thank you Rick for the explanation.

I tried to check each time I call the subroutine, the error occurred in the second time (inside my Bootstrap). I am so surprised as R is well defined since I used

AdaptiveResX=Adaptive(n1,m1,K,theta1); (K gives the value for the R)

and

AdaptiveResY=Adaptive(n2,m2,L,theta2); (L gives the value for the R)

K and L are well defined in the top of my code. That is where I am confused why this is happening?

I tried to define R inside the subroutine and call my subroutine using Adaptive(n1,m1,theta1) and Adaptive(n1,m1,theta1). This fix the error, however, it doesn't give correct results and moreover, it will always force me to make the vectors K and L to be equal all the time and not for certain cases.

I still don't know how to fix my problem

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

I just tried another thing which is to copy and paste the values of K and L from the top of the program to just before I started the bootstrap ( Step 1)

and the error disappeared and in this case I can solve my problem. The issue for me is the following

(1) when I use different values for K and L I have to remember to change these values at two places

(2) I don't understand why can't insert the K and L once and use it everywhere in the code. After all they are Global values?

Thank you

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

You are redefining L at the bottom of the DO JJ =... loop.

Don't do that. It replaces the previous dimensions of L.

At the end of the loop, I suggest you use Lower and Upper as variable names instead of L and U.

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

Thank you so much Rick

I didn't pay attention to L (lower) and U (upper) that solved everything.

Can't thank you enough!!!

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.