Macros 子集数据集时使用sas宏中的where

Macros 子集数据集时使用sas宏中的where,macros,subset,where-clause,Macros,Subset,Where Clause,我试图在子集数据集时使用宏中的where 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); 但是我得到一个错误,

我试图在子集数据集时使用宏中的where

     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);
但是我得到一个错误,变量
Acura
不在文件
SASHELP.CARS


如何继续?

您需要确保宏生成有效的SAS语法。在本例中,字符串文字周围没有引号,因此SAS将宏生成的字符串
Acura
解释为变量名

%macro subset_by_make (dsn, make);
  data temp;
    set &dsn(where = (make = "&make"));
  run;
%mend subset_by_make;