BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Salah
Quartz | Level 8

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
Rick_SAS
SAS Super FREQ

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.

View solution in original post

5 REPLIES 5
Rick_SAS
SAS Super FREQ

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.

Salah
Quartz | Level 8

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

 

 

 

 

Salah
Quartz | Level 8

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

Rick_SAS
SAS Super FREQ

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.

Salah
Quartz | Level 8

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 5 replies
  • 1122 views
  • 1 like
  • 2 in conversation