I'm trying to convert a join that works in SQL to an equivalent in PROC SQL. One table has a listing of test results. A separate table has a new test result that is less timely than the first table. I want the less timely result from the 2nd table to be repeated in the 1st table until a new 2nd table result comes along. PROC SQL;
CREATE TABLE WORK.QUERY_FOR_PROCESS_LAB_CORRELATED AS
SELECT t1.PLANT_NUM,
t1.COMMODITY_COD,
t1.COMMODITY_NAM,
t1.LAB_BOARD_DAT_COD,
t1.PLANT_NAM,
t2.Purity_Avg_pct
FROM WORK.PURITY t2
left outer join
MFGNPRO.PROCESS_LAB_CORRELATED_TAB t1
ON (t1.PLANT_NUM = t2.PLANT_NUM) AND
t2.DateTime = ( SELECT MAX(WORK.PURITY.DateTime) FROM WORK.PURITY
WHERE WORK.PURITY.DateTime <= t1.LAB_BOARD_DAT_COD);
QUIT; The error I get seems to be around MAX(WORK.PURITY.DateTime) : ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=. I'm using Enterprise Guide versoin 7.13 HF5 64-bit Thanks
... View more