Reputation: 13
I have several (55 to be exact) variables in my dataset that are large blocks of text. These variables hold the results of certain medical procedures.
I am trying to use the index function in combination with an array in SAS to identify observation where certain key words are present in one or more of the 55 results variables. For example, where the word "REPAIR" is present.
data c1;
set c;
array res results1-results55;
array outres _numeric_;
do i= 1 to dim(outres);
outres(i) = index(res(i), "REPAIR");
end;
run;
I can get my code to work when only one variable is being indexed; however, it breaks when trying to use an array to look across all 55 results variables for the word "REPAIR". I get the following error:
ERROR: Array subscript out of range at line 1338 column 19.
Any thoughts on how to debug this?
THANKS!
Upvotes: 1
Views: 211
Reputation: 51566
You asked SAS to make the array OUTRES
from all of your existing numeric variables. The number of those probably does not match the 55 variables you assigned to the RES
array.
If you want SAS to create NEW variables then you most either list them or at least tell SAS how many there should be. Here are some examples that should work.
array outres outres1-outres55 ;
array outres(55) ;
Upvotes: 1