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.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.