First, just to be technically correct, macro variables are always text. There is no such thing as a numeric macro variable. (They may look like numbers to humans, but they are text).
Next, the macro processor just replaces macro variables with their value, and the result MUST BE valid legal working SAS code. So if your macro variable has value 4,618, when this replaces the macro variable, you get yr17/4,618 which is NOT legal valid working SAS code. Can you see why this doesn't work??? It has nothing to do with macro variables.
So, the problem is that the value of variable YR17 in data set T10_1 is not a valid number, it is a character string '4,618'. So that's where you need to do the conversion to a character string without commas (or other non-digits); or create a numeric variable with value 4618 and then make that the value of the macro variable &YR17. Then you get the SAS code using the numeric version of YR17 which I shall call YR17n which reads yr17n/4618 and everyone is happy.
Which brings us to the big question ... why use a macro variable here anyway? Since yr17 is obviously a character variable, this should work without macro variables.
proc sql;
select a.Group format=Group_num., a.Value, a.yr17,
input(a.yr17,comma8.0)/input(b.yr17,comma8.0) as Pct17
from T10_1(where=(Group=2)) as a left join t10_1(where=(group=1)) as b;
quit;
... View more