Appriciate if someone of you guide me to resolve the following syntax error. I used the following code as expression in SAS DI studio in order to create the character variable called "PODVERD". Value of NEW_RENEWAL_DAY_MONTH_YEAR_char (character variable), CURRENT_DATE (character variable) will be like "18SEP" and "18SEP2018" respectively
case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then PODVERD=REPORTING_DATE_ddmonyyyy
else if (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then PODVERD=(put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
else (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.)
end
log:
7521 (case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then
7521 ! PODVERD=REPORTING_DATE_ddmonyyyy
7522 else if (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then
____
22
202
7522 ! PODVERD=(put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
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, ^, ^=, |, ||, ~, ~=.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
7523 else (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.)
____
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
As mentioned before:
put(numeric variable,to character string)
input(character string,to numeric)
Your log:
ERROR: Numeric format DATE in PUT function requires a numeric argument.
put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
Look at the above, catt() returns a string of the variable and "2018", put wants a numeric. If you want the string
NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"
Then you do not need the put.
Its clearly written in the log:
7522 else if (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then
____
22
202
7522 ! PODVERD=(put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, AND,
Count how many ( you have and how many ) you have and you will see they are unbalanced, hence why SAS was expecting one of those characters.
Your log shows an open parenthesis before the CASE statement which is not shown in your code. I believe that is causing the problem.
It may be because you have unmatched parentheses on your second line of code. Note there are 6 left parentheses and only 4 right parentheses. Below I removed what I think are the extra parenthes, and added PODVERD= on the else clause. You might want to change to (untested):
case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then PODVERD=REPORTING_DATE_ddmonyyyy else if put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then PODVERD=put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.) else PODVERD=put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.) end
My memory is that DI studio works like an interactive session. You may need to close out the unmatched parentheses by closing your DI Job and re-opening, so you get a fresh session. Or you can try submitting *); a few times and see if that clears the problem.
Still I'm getting the similar error even after correcting the code. I did ran the job in the fresh session.
Log:
2277 (case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then
2277 ! PODVERD=REPORTING_DATE_ddmonyyyy
2278 else if put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then
___
22
76
2278 ! PODVERD=put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
2279 else PODVERD=put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.)
Its put an underline right next to the problem, case when in SQL does not have if. Please read the log.
@Babloo wrote:
Appriciate if someone of you guide me to resolve the following syntax error. I used the following code as expression in SAS DI studio in order to create the character variable called "PODVERD". Value of NEW_RENEWAL_DAY_MONTH_YEAR_char (character variable), CURRENT_DATE (character variable) will be like "18SEP" and "18SEP2018" respectively
case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then PODVERD=REPORTING_DATE_ddmonyyyy else if (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then PODVERD=(put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.) else (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.) end
log:
7521 (case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then
7521 ! PODVERD=REPORTING_DATE_ddmonyyyy
7522 else if (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then
____
22
202
7522 ! PODVERD=(put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
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, ^, ^=, |, ||, ~, ~=.ERROR 202-322: The option or parameter is not recognized and will be ignored.
7523 else (put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.)
____
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.ERROR 76-322: Syntax error, statement will be ignored.
Gosh, that hurts from a proc star.
IF is not valid SQL syntax. SQL only understands case - when - else. if is taken as a column name, the horizontal position of the ERROR indicator points to the first non-blank character after the if.
Could you please help me to resolve the issue in order to create the new character variable called 'PODVERD'?
3006 (case when NEW_RENEWAL_DAY_MONTH_YEAR_char=REPORTING_DATE_ddmon and KNKATD='7' then REPORTING_DATE_ddmonyyyy
3007 when put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)>CURRENT_DATE then
3007 ! put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
3008 else put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2019"),date9.)
3009 end) as PODVERD length = 10
3010 from &SYSLAST
SYMBOLGEN: Macro variable SYSLAST resolves to WORK.W729IB79
3011 ;
ERROR: Numeric format DATE in PUT function requires a numeric argument.
ERROR: Numeric format DATE in PUT function requires a numeric argument.
ERROR: Numeric format DATE in PUT function requires a numeric argument.
As mentioned before:
put(numeric variable,to character string)
input(character string,to numeric)
Your log:
ERROR: Numeric format DATE in PUT function requires a numeric argument.
put(catt(NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"),date9.)
Look at the above, catt() returns a string of the variable and "2018", put wants a numeric. If you want the string
NEW_RENEWAL_DAY_MONTH_YEAR_char,"2018"
Then you do not need the put.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.