macro error: A character operand was found in %IF condition

I am getting the "A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &no. = 4" error on the following code:

%MACRO system(no, center);

%if &no. = 4 %then do%;

data system_%no.;
set system1 system2 (rename=(sysid=systemid));
if systemid > (&no. * 4) then delete;
if systemid < ((&no. * 4) -3) then delete;
drop systemid;
system = &no.;
center = put(strip("&center."),20.);

%MEND system;

I can't figure where the issue is coming from


  • You have a typo in your code do% instead of %do.

    Please show an example of the macro definition and macro call which produces this problem. Here is a simplified version of your macro, it does not produce the error message with these calls:

    %MACRO system(no, center);
      %if &no. = 4 %then %do;
        %put I ran &=no;
    %MEND system;

    It would be possible to produce the error message with a call like:


    In that case you could use macro quoting to avoid the problem, but I doubt that is happening in your case, from what you describe.

    When testing the macro, do not just highlight and submit part of the macro definition. You need to submit the entire macro definition in order to compile it, and then submit a macro call to invoke it.

    Be sure to review your entire log, from both the step that compiles the macro and the macro execution, to make sure there are no error messages.