I have the following code with me:
proc sql;
create Table _final_ as
select final_slot, calc_client_slot, CASE
when final_slot = calc_client_slot then 0
else 1
end as flag_
from app_port;
quit;
but when I run it, it shows error. Here is the log:
675 proc sql; 676 create Table _final_ as 677 select final_slot, calc_client_slot, CASE 678 when final_slot = calc_client_slot then 0 -- 22 76 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=. ERROR 76-322: Syntax error, statement will be ignored. 679 else 1 680 end as flag_ 681 from app_port; NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. 682 quit; NOTE: The SAS System stopped processing this step because of errors.
Help would be appreciated. Thank you.
I would use a data step:
data _final_;
set have (keep=fruit vegetable);
flag_ = (fruit ne vegetable);
run;
Is "vegetable" a variable?
Have you tried removing the parenthesis around "case"?
Do not post just the error message. Post the whole log of the step, so we see all the message(s) in context.
Copy/paste the log text into a window opened with this button:
I would use a data step:
data _final_;
set have (keep=fruit vegetable);
flag_ = (fruit ne vegetable);
run;
Well the code you posted in the question is missing a spaces between some of the words.
17 data _null_; 18 infile example ; 19 input; 20 list; 21 run; NOTE: The infile EXAMPLE is: (system-specific pathname), (system-specific file attributes) RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 proc sql;create Table _final_ asselect final_slot, calc_client_slot, CASEwhen final_slot = calc_clie 101 nt_slot then 0 else 1 end as flag_ from app_port;quit; 175 NOTE: 1 record was read from the infile (system-specific pathname). The minimum record length was 175. The maximum record length was 175.
If you just clean that mess up it seems to work without syntax errors. Of course you didn't give us any actual data to use to really test it.
39 proc sql; 40 create Table _final_ as 41 select final_slot 42 , calc_client_slot 43 , CASE when final_slot = calc_client_slot then 0 44 else 1 45 end as flag_ 46 from app_port 47 ; ERROR: File WORK.APP_PORT.DATA does not exist. 48 quit;
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: