12-07-2014 12:17 AM
I have a very simple example that I cannot get to work and I have no idea why. The macro variable is recognized in the put statement but not when used to pull the data in a datastep. Please help.
input one $ two $ three $;
0110 Mark 001129
if one = '0110' then call symputx('test',three);
where three = &test;
29 %put &test;
31 data test;
32 set data;
33 where three = &test;
ERROR: WHERE clause operator requires compatible variables.
12-07-2014 01:08 AM
Your macro variable is being created properly, but you are using it to generate invalid SAS syntax.
WHERE THREE = 001129 ;
SAS is telling you that THREE is a character variable so you cannot compare it to a number. In SAS literal strings need to be enclosed in quotes. So this would work:
WHERE THREE = "001129" ;
You will need to use double quote characters so that the macro variable reference will be expanded.
WHERE THREE = "&test" ;
Need further help from the community? Please ask a new question.