I am trying to run the following code and I am running into this error:
proc sql; create table data_new as select *, case when a is not null then 500 else when b>=60 and c=0 then 400 else when d <6 and Days_Arrears>e then 300 else when d <6 and Days_Arrears>e then 200 else when d <6 and Days_Arrears=e then 100 else when f = 'available' then 50 else f = 'vacant' then 25 else 0 end as Points from data_old; quit;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 proc sql; 74 75 create table data_new as select *, 76 77 case when a is not null then 500 78 79 else when b>=60 and c=0 then 400 ____________ 22 76 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, '.', /, <, <=, <>, =, >, >=, AND, EQ, EQT, GE, GET, GT, GTT, LE, LET, LT, LTT, NE, NET, OR, ^=, |, ||, ~=. ERROR 76-322: Syntax error, statement will be ignored.
Does that answer you question? -> just remove the multiple "else" to keep one at the very end.
proc sql; create table data_new as select *, case when a is not null then 500 when b>=60 and c=0 then 400 when d <6 and Days_Arrears>e then 300 when d <6 and Days_Arrears>e then 200 when d <6 and Days_Arrears=e then 100 when f = 'available' then 50 when f = 'vacant' then 25 else 0 end as Points from data_old; quit;
@ed_sas_member has replied to your post while I was still typing my answer ...
I was wondering why nobody had replied to your post yet, because syntax errors are among the easiest errors to resolve. Here's why: The SAS documentation is really good, so that a comparison of a piece of SAS code and the syntax shown there quickly reveals the difference which constitutes the syntax error.
In your example, use, e.g., "case when" (without quotes) as the search terms and the first link returned will be:
(which is the correct one [assuming SAS version 9.4] because the error occurred in a PROC SQL step, not in FedSQL etc.).
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.