error (EXECUTION)invalid subscript or subscript out of.......
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 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.
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.
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.
thank you
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.