Macros 使用SAS宏,是否有方法创建名称带有空格的变量?

Macros 使用SAS宏,是否有方法创建名称带有空格的变量?,macros,sas,Macros,Sas,我想使用宏在数据集中创建一个变量。变量名包含空格。通常在SAS中,我必须用撇号将名称括起来:“var_name”n。在宏中,我尝试使用%(str)隐藏撇号: 例如: %macro test(varname); %str(')&varname.%str('n)="" %mend; 但这似乎不起作用 您可以使用%符号转义单引号,并使用%unquote函数解析引用,如下所示: %macro test(varname); %unquote(%str(%'&varname.%'n

我想使用宏在数据集中创建一个变量。变量名包含空格。通常在SAS中,我必须用撇号将名称括起来:“var_name”n。在宏中,我尝试使用%(str)隐藏撇号:

例如:

%macro test(varname);
%str(')&varname.%str('n)=""
%mend;

但这似乎不起作用

您可以使用
%
符号转义单引号,并使用
%unquote
函数解析引用,如下所示:

%macro test(varname);
    %unquote(%str(%'&varname.%'n))="";
%mend;
源自