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
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!
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.