BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buechler66
Barite | Level 11

I'm trying to recode RuleFlag to the value of '1' (&Rule_Order_Char) when the following conditions are met:  

 

A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL or A.ACTUAL_DLVRY_DATE > B.ACTUAL_DLVRY_DATE AND a.RULEFLAG = "-"

 

But I'm getting the error:  

 

ERROR: Operand of WHEN clause 1 is not the same data type as the CASE operand.

 

Am I using Case the wrong way? Is there another way to achieve the desired recoding during a Select statement? ny help would be much appreciated.

 

2224          proc sql;
2225          create table QueryData&ZIP5._&RULE_ORDER_CHAR as
SYMBOLGEN:  Macro variable ZIP5 resolves to 00926
SYMBOLGEN:  Macro variable RULE_ORDER_CHAR resolves to 1
2226          select DISTINCT %unquote(%str(%')&ANALYSIS_DESC.%str(%')) as rule_nm length = 58,
SYMBOLGEN:  Macro variable ANALYSIS_DESC resolves to TEST
2227                      a.actual_dlvry_date as ad_dt,
2228                      a.imb_code length = 31,
2229                      &RULE_ORDER as rule_order,
SYMBOLGEN:  Macro variable RULE_ORDER resolves to 1
2230                      a.imb_dlvry_zip_5,
2231                      CASE a.RULEFLAG
2232                          WHEN A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL or
            A.ACTUAL_DLVRY_DATE > B.ACTUAL_DLVRY_DATE
 AND a.RULEFLAG = "-" THEN "&RULE_ORDER_CHAR"
SYMBOLGEN:  Macro variable RULE_ORDER_CHAR resolves to 1
2233                      END as rule_flag
2234          from QueryData&ZIP5 as a
SYMBOLGEN:  Macro variable ZIP5 resolves to 00926
2235          inner join QueryData&ZIP5 as b
SYMBOLGEN:  Macro variable ZIP5 resolves to 00926
2236          on a.imb_code=b.imb_code
2237          where a.source="A" and b.source="B";
ERROR: Operand of WHEN clause 1 is not the same data type as the CASE operand.
NOTE: A CASE expression has no ELSE clause. Cases not accounted for by the WHEN clauses will result in a missing value for the
      CASE expression.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
2238          quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Remove the a.ruleflag after the word Case. 

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

Remove the a.ruleflag after the word Case. 

 

 

buechler66
Barite | Level 11
Worked. Thanks for your time!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1246 views
  • 1 like
  • 2 in conversation