BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xiangzaier
Calcite | Level 5


  error (EXECUTION)invalid subscript or subscript out of.......

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Currently, you have the statements 

	if sum(flag) < n then
		ui = ui[loc(flag)=1];
	else if sum(flag)= n then
		ui= ui;

I suspect you meant to write

	if sum(flag) < n then
		ui = ui[loc(flag=1)];   /* <== CHANGE THIS LINE */
	else if sum(flag)= n then
		ui= ui;

 

Be aware that if no element of FLAG equals 1, then the LOC function returns an empty matrix.

which would result in an error.  

View solution in original post

7 REPLIES 7
xiangzaier
Calcite | Level 5
thank you for your help
ballardw
Super User

@xiangzaier wrote:
thank you for your help

It is best practice to copy from the LOG the submitted code along with the error  message. Paste into a code box opened with the {I} or running man icon. Many times the position and other information in the log gives clues as the where the error occurs. So just the error message isn't quite as helpful.

xiangzaier
Calcite | Level 5
the aim is to calculate robust reference interval and confidence interval of reference value(upper,lower)
PaigeMiller
Diamond | Level 26

Your matrices are a certain size, let's say nxk. If you have a subscript which refers to column k+1 or refers to row n+1, or refers to row or column <=0, you will get the error.

 

You can debug this code by putting PRINT or SHOW commands in your code that will write to the log the actual sizes of the matrices and the values of subscripts used.

--
Paige Miller
Rick_SAS
SAS Super FREQ

Currently, you have the statements 

	if sum(flag) < n then
		ui = ui[loc(flag)=1];
	else if sum(flag)= n then
		ui= ui;

I suspect you meant to write

	if sum(flag) < n then
		ui = ui[loc(flag=1)];   /* <== CHANGE THIS LINE */
	else if sum(flag)= n then
		ui= ui;

 

Be aware that if no element of FLAG equals 1, then the LOC function returns an empty matrix.

which would result in an error.  

xiangzaier
Calcite | Level 5
thank you,the the col of s is 1000,but it still error,i will debug again

SAS Innovate 2025: Save the Date

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

Save the date!

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
  • 7 replies
  • 1172 views
  • 0 likes
  • 4 in conversation