【发布时间】:2020-06-30 05:34:18
【问题描述】:
我正在尝试使用 SAS 中宏变量的字符串值创建列。 我有一个名为 want7 的数据集,其中有一列名为“ID”。我想创建一个名为 want8 的新数据集,其中包含一个名为“ID1”的新列,方法是将其动态链接到 &string1(如列名链接到 &string1),但列的值应等于“ID”的值'want7 中的列。我该怎么做呢?提前致谢。由于我对 SAS 比较陌生,所以我只复制和粘贴了我能写的内容。
%let string1 = ID1;
data want8; set want7;
/*Something like &string1 = ID*
run;
【问题讨论】:
-
注意:所有 SAS 宏变量值都是字符(即文本)
"Macro variables are tools that enable you to dynamically modify the text in a SAS program through symbolic substitution. You can assign large or small amounts of text to macro variables, and after that, you can use that text by simply referencing the variable that contains it."documentation.sas.com/…