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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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