Whenever SAS encounters a macro variable in code, it replaces the macro variable with its actual value, and then runs the code with these replacements made. So, for this code:
select * ,
case
when &value. = 'be' then '010'
when &value. = 'gc' then '001'
End as newvar
This is the code that is actually executed:
select * ,
case
when be = 'be' then '010'
when be = 'gc' then '001'
End as newvar
SQL thinks BE is the name of a variable in the table. (Do you understand why SAS thinks BE is the name of a variable in the table?) So this code only makes sense if the table that SQL is working on (TEMPTBL) has a variable named BE. Does it?
A much better approach to create programs with macro variables is to get the code to work without macro variables first, and then substitute the macro variables into the code. But you haven't done that, and so it is highly recommended.
So, please tell us, what is the code you want to have executed here, without macro variables.
Finally, when you are getting errors in the log, please show us (ALWAYS) the relevant parts of the log.
... View more