Search code examples
sassas-macro

What am I doing to generate the SAS error: "Required operator not found in expression"?


The following code is generating the above error. I'm looking for an explanation. Please help.

%GLOBAL var;
%LET var = 1;

%MACRO test;
%IF &var. in (1,2) %THEN %DO;
    %PUT &var.;
%END;
%MEND;

%test;

ERROR: Required operator not found in expression: &var. in (1,2)

Solution

  • Use of "In" in the %IF needs to be changed to the below code. or use %index function

    %GLOBAL var;
     %LET var = 1;
    
     %MACRO test;
     %IF **&var.=1 or &var.=2** %THEN %DO;
         %PUT &var.;
     %END;
    
     %if %index
     %MEND test;
    
     %test;