I am trying to run the following case statement in SAS but keep getting an error:
,CASE
WHEN ((MM,&EOY.) - (MM,Start_Date)) > Term_Length__months_ THEN 'Term_Length__months_'
ELSE ((MM,&EOY.) - (MM,Start_Date)) END AS Flow_Months_2019
,CASE
WHEN ((MM,&EOY.) - (MM,Start_Date)) > Term_Length__months_ THEN '0'
ELSE Term_Length__months_ - ((MM,&EOY.) - (MM,Start_Date)) END AS Flow_Months_Contract
ERROR 79-322: Expecting a (.
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, -, '.', /, <, <=, <>, =, >, >=, AND, EQ, EQT,
GE, GET, GT, GTT, LE, LET, LT, LTT, NE, NET, NOT, OR, ^, ^=, |, ||, ~, ~=.
Please post a minimal working example
Show us the log of the entire PROC SQL, and the preceding PROC or DATA step, where this error happens. Click on the {i} icon and paste the log into the window that appears — DO NOT SKIP THIS STEP.
No wonder SAS is confused. Your code looks really strange to me also.
What does this mean?
((MM,&EOY.) - (MM,Start_Date))
Making a complete guess that
(MM,&EOY.)is intended to do something like calculate the number of months(??) from a given value to "end of year" then the actual calculation is missing. In MM and &EOY. are supposed to be date values then perhaps you are missing a function like INTCK.
If the values are NOT SAS date values then you need to provide:
values of MM, &EOY. and START_date and make sure we can tell whether the values are character or numeric.
If the values ARE supposed to be SAS date values then you need to tell us what this is supposed to actual do as the likely functions involved, INTCK or possibly INTNX, require an INTERVAL, such as 'month' to use.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.