转义字符在 SAS 中解释为数组 [英] Escape characters interpreted as array in SAS
问题描述
我使用的是 SAS 大学版.
I am using SAS university edition.
我想为以下数据集使用一个名为Age(years)"而不是Age_years"的变量.我知道()"将被解释为数组,而我需要它成为变量的一部分.
I want to have a variable named "Age(years)" instead of "Age_years" for the following data set. I understand that "()" will be interpreted as array, while I need this to be a part of the variable.
data data;
input Name $ Age_years Gender $;
datalines;
Dino 6 male
Rita 5 female
Aurora 6 female
Joko 7 male
;
run;
我访问以下行时的确切错误是错误:引用了未声明的数组:年龄.错误:变量年龄尚未声明为数组."
The exact error when I am accessing the following line is " ERROR: Undeclared array referenced: Age. ERROR: Variable Age has not been declared as an array."
data data;
set data;
Age(years)=Age_years;
run;
我已经检查了转义这个括号字符的可能性,这样它就不会被解释为数组,如下所示:SAS 中的特殊字符 但是 % 符号无助于转义 () 字符.如何在 SAS 中执行此操作?
I have checked for possibility of escaping this bracket characters so that it won't be interpreted as array as in here : Special Characters in SAS however the % symbol does not help to escape the () characters. How can I do this in SAS?
推荐答案
您可以将n"称为修饰符.您可以将一些附加到引用文字的末尾以指定 SAS 应如何处理它:
You could call that 'n' a modifier. There are a few you can append to the end of a quoted literal to specify how SAS should treat it:
'my variable'n
将被视为名为 'my variable' 的变量
'my variable'n
will be treated as a variable called 'my variable'
'14AUG2017'd
将被视为代表今天日期的数字
'14AUG2017'd
will be treated as a number representing today's date
'14AUG2017:09:53:00'dt
将被视为代表今天日期和时间的数字
'14AUG2017:09:53:00'dt
will be treated as a number representing today's date and time
'49'x
将被视为字母 A,此处由其十六进制值指定.
'49'x
will be treated as the letter A, here specified by its hexadecimal value.
...以及我可能忘记的其他人.
...and others I may have forgotten.
请注意,使用非 SAS 有效名称不被认为是好的做法.
Note that it is not considered good practice to use non SAS-valid names.
这篇关于转义字符在 SAS 中解释为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!