0
votes

I am using the below but am receiving an error shown below. The part of the code that is throwing the error is MAX(EX_DT) EXPIRATION_DT and it underlines EXPIRATION_DT.

Thoughts?


                             22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, AS, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

LEFT OUTER JOIN
(select LN_NO, 
MAX(EX_DT) EXPIRATION_DT
FROM R1.SAMPLE_TABLE
GROUP BY LN_NO, 
EXPIRATION_DT) T1
ON T1.NUM = TL.NUM
2

2 Answers

1
votes

MAX(EX_DT) EXPIRATION_DT

need to change to

MAX(EX_DT) AS EXPIRATION_DT

0
votes

You need to use the AS keyword if you want to give a new name to the value you are selecting. Otherwise SAS is expecting that second token to be the LABEL that you want to attach to the variable.

So the syntax is

expression string_literal

or

expression as varname

To specify both you can use

expression as varname string_literal

But you can use keywords to set the LABEL and other attributes like LENGTH, FORMAT, INFORMAT.

catx(', ',lastname,firstname) as fullname label='Person Name' length=40