Not sure why this isn't working, shouldn't I have "end" in the location of the error?
28 proc sql;
29 create table temp as
30 select contract_number, sum(enrollment) as parent_enrol,
31 case when (calculated parent_enrol lt 50000) then 1
32 else case when parent_enrol le 200000 then 2
33 else case when (calculated parent_enrol gt 200000) then 3
34 else 4
35 end as parent_size
__
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~,
~=.
ERROR 76-322: Syntax error, statement will be ignored.
36 from D107342.AP15747022_Master
37 group by contract_number;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
38 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time
EDIT: Too many cases and elses here.
28 proc sql; 29 create table temp as 30 select contract_number, sum(enrollment) as parent_enrol, 31 case when (calculated parent_enrol lt 50000) then 1 32 else case when parent_enrol le 200000 then 2 33 else case when (calculated parent_enrol gt 200000) then 3 34 else 4 35 end as parent_size
Correct syntax
28 proc sql;
29 create table temp as
30 select contract_number, sum(enrollment) as parent_enrol,
31 case when (calculated parent_enrol lt 50000) then 1
32 when parent_enrol le 200000 then 2
33 when (calculated parent_enrol gt 200000) then 3
34 else 4
35 end as parent_size
@Batman wrote:
Not sure why this isn't working, shouldn't I have "end" in the location of the error?
28 proc sql;
29 create table temp as
30 select contract_number, sum(enrollment) as parent_enrol,
31 case when (calculated parent_enrol lt 50000) then 1
32 else case when parent_enrol le 200000 then 2
33 else case when (calculated parent_enrol gt 200000) then 3
34 else 4
35 end as parent_size
__
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~,
~=.ERROR 76-322: Syntax error, statement will be ignored.
36 from D107342.AP15747022_Master
37 group by contract_number;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
38 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time
Still getting an error even with your modification
27 proc sql;
28 create table temp as
29 select contract_number, sum(enrollment) as parent_enrol,
30 case when calculated parent_enrol lt 50000 then 1
31 else when calculated parent_enrol le 200000 then 2
__________
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, '.', /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~,
~=.
ERROR 76-322: Syntax error, statement will be ignored.
32 else when calculated parent_enrol gt 200000 then 3
33 else 4
34 end as parent_size
35 from D107342.AP15747022_Master
36 group by contract_number;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
37 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.