-1

I tried to use macro in data step to exclude rows that does not match the conditions, but it won't work. here is my code

%macro bbb(a);
data grade&a.;
set grade&a.;
if ID='schoolgrade&g.score1' then output;
run;
%mend;
%match(4)

so, i cannot use macro in the if statement? what else can i do? Thanks!

Joe
  • 62,789
  • 6
  • 49
  • 67
Arya
  • 1
  • 2
  • Does this answer your question? [Why won't my macro variable resolve?](https://stackoverflow.com/questions/27946244/why-wont-my-macro-variable-resolve) – Joe Sep 20 '21 at 18:14
  • Also - next time, please include the error or whatever is telling you "this won't work" - otherwise it's not always possible to tell what your issue is! – Joe Sep 20 '21 at 18:15

1 Answers1

1

The macro processor will ignore strings bounded by single quote character. Use the double quote character instead.

Also what is the source of the macro variable G? Or did you mean to reference the macro variable A which is the parameter define to the macro?

So this code

if ID="schoolgrade&a.score1" then output;

Will find the observations with ID value equal to "schoolgrade4score1".

Tom
  • 47,574
  • 2
  • 16
  • 29