BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASuser4321
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION
6 REPLIES 6
andreas_lds
Jade | Level 19

Is "vegetable" a variable?

Have you tried removing the parenthesis around "case"?

Kurt_Bremser
Super User

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:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

 

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10
Please post a ready to paste example including a data step creating a mock table for _final_ that demonstrates the error.
--fja
Ksharp
Super User
NO need parent character if using CASE operator:

proc sql;
create Table _final_ as
select weight, height, CASE
when weight = height then 0
else 1
end as flag_
from sashelp.class;
quit;
Tom
Super User Tom
Super User

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;

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!
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
  • 6 replies
  • 711 views
  • 3 likes
  • 6 in conversation