我正在尝试在SAS中运行PROC SQL步骤但由于某种原因继续遇到错误。这是我的代码:
PROC SQL;
CREATE TABLE NewTable AS
SELECT a.ID as ID,
a.Group as Group,
a.2014_04,
b.2014_04,
c.2014_04,
b.2014_04/a.2014_04,
c.2014_04/a.2014_04
FROM work.TESTDATA a
LEFT OUTER JOIN work.TESTDATA_0000 b on a.ID
LEFT OUTER JOIN work.TESTDATA_0001 c on b.ID;
QUIT;
我收到的错误如下:
ERROR 22-322: Syntax error, expecting one of the following: a name, *.
ERROR 200-322: The symbol is not recognized and will be ignored.
这些错误似乎集中在变量上。错误是否与我引用变量的方式有关?
答案 0 :(得分:1)
在SAS中,变量名必须以字符或下划线开头。因此,您的2014_
列在SAS中无效。
试试这样:
PROC SQL;
CREATE TABLE NewTable AS
SELECT a.ID as ID,
a.Group as Group,
a.'2014_04'n,
b.'2014_04'n,
c.'2014_04'n,
b.'2014_04'n/a.'2014_04'n,
c.'2014_04'n/a.'2014_04'n
FROM work.TESTDATA a
LEFT OUTER JOIN work.TESTDATA_0000 b on a.ID
LEFT OUTER JOIN work.TESTDATA_0001 c on b.ID;
QUIT;
'<invalid_sas_var_name>'n
允许您仍然使用原本无效的SAS变量名称