SELECT IIf([Group]="07M","GWB","EIA") & IIf(Left([ISSUE_DATE],4) <"2003","2003",Left([ISSUE_DATE],4)) AS IY
IY
EIA2003 |
EIA2004 |
EIA2005 |
EIA2006 |
EIA2007 |
EIA2008 |
EIA2009 |
EIA2010 |
EIA2011 |
EIA2012 |
EIA2013 |
EIA2014 |
EIA2015 |
EIA2016 |
EIA2017 |
EIA2018 |
EIA2019 |
EIA2020 |
GWB2016 |
GWB2017 |
GWB2018 |
GWB2019 |
GWB2020 |
CASE WHEN EPLAN.Group = "07M" THEN "GWB"
5665 ELSE "EIA"
5666 AND WHEN YEAR(ISSUE_DATE) < 2003 THEN 2003
____
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.
5667 ELSE YEAR(ISSUE_DATE)
5668 END AS IY
I'm in need of some assistance. At the very top of this post is the SQL code that I'm trying to replicate. The IY field that's created is the column that follows and the SAS code that I'm running comes last. I'm not sure how to create this nested if formula using the CASE WHEN function.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.