使用SAS宏,有没有办法创建名称有空格的变量?

时间:2013-05-29 08:41:42

标签: macros sas

我想使用宏在我的数据集中创建一个变量。变量名称包含空格。通常在SAS中,我必须用撇号括起名称:'var_name'n。在宏中,我试图使用%(str)来掩盖撇号:

例如:

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

但这似乎不起作用。

1 个答案:

答案 0 :(得分:6)

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

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

派生自Sample 25076: Resolve a macro variable within single quotes

相关问题