1

While running the code mentioned below, I'm getting the error "ERROR 22-322: Expecting a name." and the affected code is 'END AS "Z"'. I'm not sure where I'm going wrong with this.

proc sql;
SELECT CASE
   WHEN REGION IS NULL THEN ZONE
   ELSE REGION
   END AS "Z",
James Z
  • 12,209
  • 10
  • 24
  • 44
sklal
  • 175
  • 3
  • 15

1 Answers1

1

SAS didn't recognise the column name as it is not correct syntax. Your options are:

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

or

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

I suggest the first approach as there is no need to make Z a literal (eg spaces, special chars etc).

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
  • 1
    It worked, I used the second with "Z"n as there were other column names with spaces like "Product Code". Thank you so much :) – sklal Mar 18 '18 at 15:50