I would like to check wether a variable is in a list of values. If so, I want the macro to return the value 1, else return the value 0. Pseudo code:
%Macro MyMacro(country, list = USA UK FIN GER) \minoperator;
%if &country. in (&list) %then %do; answer= 1;
%end;
%else %do; answer= 0;
%end;
&answer;
%mend;
Now for instance, creating a macro variable:
%let MyBinaryVariable = %MyMacro(USA, list = (GER NOR) );
* Now MyBinaryVariable should be 0, since USA is not in the list provided. ;
I hope it is clear what I want to achieve. Any advice on how to do this properly?
... View more