BookmarkSubscribeRSS Feed
deenap29
Calcite | Level 5

For the case statement below, I keep getting the error in red. Not sure where a then is missing? Please help!!! 

 

70 /* Include Owner? */
71 (CASE
72 WHEN THEN 'N'
___
79
73 WHEN THEN 'N'
___
79
ERROR 79-322: Expecting a THEN.

74 WHEN '949 IRVING' = t1.current_owner_fn THEN 'N'
75 WHEN 'CLAIMS INTAKE - LIBERTY MUTUAL (CL)' = t1.current_owner_fn THEN 'N'
76 WHEN 'CLAIMS INTAKE - LIBERTY MUTUAL (CL) SUPPORT' = t1.current_owner_fn THEN 'N'
77 WHEN 'GENERAL AM INBOX - LIBERTY MUTUAL (CL)' = t1.current_owner_fn THEN 'N'
78 WHEN 'LIBERTY MUTUAL COMMERCIAL SUBRO' = t1.current_owner_fn THEN 'N'
79 WHEN 'LIBERTY MUTUAL INS - COMMERCIAL CLAIMS' = t1.current_owner_fn THEN 'N'
80 ELSE 'Y'
81 END) FORMAT=$CHAR43. LABEL="Include Owner?" AS 'Include Owner?'n,

 

 

Case statement: 

 

CASE
WHEN THEN 'N'
WHEN THEN 'N'
WHEN '949 IRVING' = t1.current_owner_fn THEN 'N'
WHEN 'CLAIMS INTAKE - LIBERTY MUTUAL (CL)' = t1.current_owner_fn THEN 'N'
WHEN 'CLAIMS INTAKE - LIBERTY MUTUAL (CL) SUPPORT' = t1.current_owner_fn THEN 'N'
WHEN 'GENERAL AM INBOX - LIBERTY MUTUAL (CL)' = t1.current_owner_fn THEN 'N'
WHEN 'LIBERTY MUTUAL COMMERCIAL SUBRO' = t1.current_owner_fn THEN 'N'
WHEN 'LIBERTY MUTUAL INS - COMMERCIAL CLAIMS' = t1.current_owner_fn THEN 'N'
ELSE 'Y'
END

1 REPLY 1
SASJedi
SAS Super FREQ

Your case expression has no logical expression. It should look something like this:

proc sql;
select distinct 
       Make
      , CASE (/* Logical Expression */ Type )
          WHEN 'SUV' THEN 'N'
          ELSE 'Y'
        END
   from sashelp.cars
;
quit;

or like this:

proc sql;
select distinct 
       Make
      ,CASE 
         WHEN (type='SUV') THEN 'N'
         ELSE 'Y'
       END
   from sashelp.cars;
quit;
 e

 

Check out my Jedi SAS Tricks for SAS Users

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 1 reply
  • 955 views
  • 0 likes
  • 2 in conversation