Proc SQL : 期待一个名字,Case When,End AS

Proc SQL : Expecting a name , Case When, End AS

当 运行 下面提到的代码时,我收到错误 "ERROR 22-322: Expecting a name.",受影响的代码是 'END AS "Z"'。我不确定我哪里出错了。

proc sql;
SELECT CASE
   WHEN REGION IS NULL THEN ZONE
   ELSE REGION
   END AS "Z",

SAS 无法识别列名,因为它的语法不正确。您的选择是:

proc sql;
SELECT CASE
   WHEN REGION IS NULL THEN ZONE
   ELSE REGION
   END AS Z /* without quotes */

proc sql;
SELECT CASE
   WHEN REGION IS NULL THEN ZONE
   ELSE REGION
   END AS "Z"n /* as name literal */

我建议第一种方法,因为不需要 Z 文字(例如空格、特殊字符等)。