Well Marion, I think that the main problem your program encounters is mixing macro-language and SAS language : both can work together, but not at the same time.
When you submit a program including both macro and normal statements, the macro facility is compiled and executed first ; it should return text that is considered as SAS code. And then the transform program is executed.
For example, when you submit :
DATA _NULL_ ;
SET sashelp.class (OBS = 1) ;
%LET MVage = age ;
RUN ;
PROC PRINT DATA = sashelp.class (WHERE = (age > &MVage)) ;
RUN ;
The first executed statement is
%LET MVage = age ;
it does not mean that the VALUE of the SAS variable AGE is copied to the macro-variable MVage, but that the TEXT "AGE" is now the value of the macro-variable.
Then the Data Step is processed :
DATA _NULL_ ;
SET sashelp.class ;
RUN ;
Then the &MVage in the WHERE clause is transformed :
&MVage --> AGE
So at the end, the executed PRINT procedure is :
PROC PRINT DATA = sashelp.class (WHERE = (age > age)) ;
RUN ;
As the condition is always false (a value can't be > than itself !), nothing is printed.
I think that's why your way of doing should never come to a correct result.
But why using macro-language in that case ? Just skip the macro-things and try just this :
data result.agtxti_critpi /DEBUG;
set agtxti_copy;
dsid=open("work.probable");
nobs=attrn(dsid,"nobs");
do i=1 to nobs;
rc = fetchobs(dsid,1);
mot1=getvarc(dsid,varnum(dsid,'MOT1'));
ARR_M1 = (index(txtaga||txtagb,mot1)+index(txtagc||txtagd,mot1)+index(txtage||txtagf,mot1));
end;
dsid=close(dsid);
run;