且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SAS 宏,将值作为字符串传递给 where 子句

更新时间:2023-02-12 16:20:19

宏变量不能用单引号解析.您还缺少 FROM 子句,并且宏参数是作为位置提供的(而不是名称=值对).请尝试以下操作:

Macro variables will not resolve in single quotes. You are also missing the FROM clause, and the macro parameter was being provided as positional (instead of name=value pair). Try the following:

%macro refreshments(beverage_type=);
  proc sql;
  select * 
    from YOURTABLE
    where drink_type = "&beverage_type";
%mend;

%refreshments(beverage_type=Sprite);