I have a macro named ABC with the argument BP_VAR. "BP" stands for "Body Part" and the values I can specify for BP_VAR are Arm, Leg and Head.
Inside the macro, there is a datastep and inside it I had code like this.
If &BP_VAR = "Arm" then do;
... some statements...
end;
And there is similar code for Leg and Head. But it wouldn't work so I found a way around it, although if you have comments on why the above didn't work then I'd be interested to hear it.
So &BP_VAR takes on values Arm or Leg or Head. Thus you are testing if the value of &BP_VAR (let's assume it is Arm) is equal to the text string "Arm". In other words, when SAS executes, it is trying to execute
if Arm = "Arm" then do;
and this probably produces an error because you don't have a variable in your data set named Arm. I'm not sure what you are trying to do, so I can't produce code that will work for you here. Could you explain what you are trying to do?
As a wild guess, are you trying to test to see if the macro variable &BP_VAR has the value "Arm"??? This won't work either because even if &BP_VAR contains Arm, it doesn't match "Arm" because &BP_VAR doesn't contain double-quotes. And you would need to use %IF and not IF. Like this
%if &bp_var=Arm %then %do;
but maybe that's not what you want, I was guessing. So really, please explain what you are trying to do in words, not in code. Please explain the big picture of what you are trying to do.
... View more