You have to tell SAS that you want the macro processor to treat the text IN as an operator. You also need to tell it what delimiter to use between the items in the list.
%macro loop_thru_fcat_list / minoperator mindelimiter=' ';
You also have to watch out for text like OR that might be confused for an operator. So use %QSCAN() instead of %SCAN().
Also your macro is referencing a macro variable that is neither an input nor a local macro variable. Much better to be explicit about the source of the inputs.
%macro loop_thru_fcat_list(fcat_name) / minoperator mindelimiter=' ';
%local i next_name;
%do i=1 %to %sysfunc(countw(&fcat_name));
%let next_name = %qscan(&fcat_name, &i);
%if not(&NEXT_NAME. in C1_EST FIBRINO) %then %do;
%PUT &=i &=NEXT_NAME ;
%end;
%end;
%mend loop_thru_fcat_list;
Let's test it:
11 %loop_thru_fcat_list(a or b);
I=1 NEXT_NAME=a
I=2 NEXT_NAME=or
I=3 NEXT_NAME=b
If we use %SCAN() instead of %QSCAN() you can see the error:
12 %macro loop_thru_fcat_list(fcat_name) / minoperator mindelimiter=' ';
13 %local i next_name;
14 %do i=1 %to %sysfunc(countw(&fcat_name));
15 %let next_name = %scan(&fcat_name, &i);
16 %if not(&NEXT_NAME. in C1_EST FIBRINO) %then %do;
17 %PUT &=i &=NEXT_NAME ;
18 %end;
19 %end;
20 %mend loop_thru_fcat_list;
21
22 %loop_thru_fcat_list(a or b);
I=1 NEXT_NAME=a
ERROR: Operand missing for IN operator in argument to %EVAL function.
ERROR: The macro LOOP_THRU_FCAT_LIST will stop executing.
... View more