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):
Remove the a.ruleflag after the word Case.
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: