0

I'm trying to use where in a macro when subsetting a dataset

     option mprint mlogic;

     %macro subset_by_make (dsn, make);
        data temp;
            set &dsn(where = (make = &make));
    run;
    %mend subset_by_make;
    %subset_by_make(sashelp.cars, Acura);

but I'm getting an error that Variable Acura is not on file SASHELP.CARS

How do I proceed?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83

1 Answers1

0

You need to make sure that your macro generates valid SAS syntax. In this case you did not include quotes around the string literal, so SAS interpreted the string Acura generated by the macro as a variable name.

%macro subset_by_make (dsn, make);
  data temp;
    set &dsn(where = (make = "&make"));
  run;
%mend subset_by_make;
Tom
  • 47,574
  • 2
  • 16
  • 29