Good afternoon all I am trying to convert SQL code into SAS code and keep getting multiple errors, I'm guessing because some of the expressions I am using do not translate. Can anyone give me any suggestions? Here is the code I am using: PROC SQL;
CREATE TABLE work.first_chemo AS
SELECT
CASE WHEN Month(DischargeDTS) > 9
THEN YEAR(DischargeDTS) + 1
ELSE YEAR(DischargeDTS)
END as Fiscal_Year
, b.MRN AS mrn
, MIN(DischargeDTS) AS date
,CASE WHEN LEN(c.CPT) ^= 5
THEN c.HCPCS
ELSE c.CPT
END AS HCPCS
FROM epicfin.HospitalAccount a
LEFT JOIN epicpat.Patient b
ON a.PatientID= b.PatientID
LEFT JOIN Epicfin.HospitalTransaction c
ON a.HospitalAccountID = c.HospitalAccountID
;QUIT; and this is the log with the errors: 26 PROC SQL;
27 CREATE TABLE work.first_chemo AS
28 SELECT
29 CASE WHEN Month(DischargeDTS) > 9
30 THEN YEAR(DischargeDTS) + 1
31 ELSE YEAR(DischargeDTS)
32 END as Fiscal_Year
33 , b.MRN AS mrn
34 , MIN(DischargeDTS) AS date
35 ,CASE WHEN LEN(c.CPT) ^= 5
36 THEN c.HCPCS
37 ELSE c.CPT
38 END AS HCPCS
39 FROM epicfin.HospitalAccount a
40 LEFT JOIN epicpat.Patient b
41 ON a.PatientID= b.PatientID
42 LEFT JOIN Epicfin.HospitalTransaction c
43 ON a.HospitalAccountID = c.HospitalAccountID
44 ;
ERROR: Function MONTH requires a numeric expression as argument 1.
ERROR: Expression using greater than (>) has components that are of different data types.
ERROR: Function YEAR requires a numeric expression as argument 1.
ERROR: Expression using addition (+) requires numeric types.
ERROR: Function YEAR requires a numeric expression as argument 1.
ERROR: Result of WHEN clause 2 is not the same data type as the preceding results.
ERROR: Function LEN could not be located.
ERROR: Expression using not equals (^=) has components that are of different data types.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
44 ! QUIT;
NOTE: The SAS System stopped processing this step because of errors. Any assistance provided would be greatly appreciated. Thanks
... View more