Hello, I am using SAS EG version 7.1. I am trying to build a bit of code where it can be used for the last 6 years. I am selecting the same fields, no matter the month. Unfortunately my piece of code has an error, due to the field not being in previous datasets where the field was added into the file. The 2 errors are as follows: ERROR: Column Cue5 could not be found in the table/view identified with the correlation name B. ERROR: Result of WHEN clause 2 is not the same data type as the preceding results. PROC SQL;
CREATE TABLE Data AS
SELECT a.*
,b.Cue1
,b.Cue2
,b.Cue3 AS Cue3_Old
,b.Cue4 AS Cue4_Old
,(CASE WHEN Version < '4' THEN .
WHEN Version >= '4' THEN b.Cue5
ELSE . END) AS Cue5_Old
FROM File AS a
LEFT JOIN extra_data AS b ON a.id = b.id;
QUIT; On the File that I am joining on the extra_data to, Cue5 doesn't exist before version 4, so I thought in the case when statement, it would put a missing value. It seems that it is failing due to Cue5 not existing in the dataset extra_data. All fields are numeric. The code works perfect for version 4 and above. Does anyone know how to fix it? Any help would be greatly appreciated! Thank you!
... View more