Hi....I am trying to sum the number of Course Hours for each StudentUID in the program that they are enrolled. The problem is that there are duplicate records for the grouped variables of StudentUID, Initial Program, Level and CourseName. I tried to include "First.CourseName" in the case when statement but got an error message. I need to only have unique records to be selected and then sum those but I can't seem to get what I need. Maybe there is a better way to get the Program Hours. Thanks.
proc sql noprint;
create table List109G50 as
select
*,
sum(select
B.ProgHours
from ((select
List109G4.CourseName,
(case when not missing(List109G4.'Course Hours'n)
then List109G4.'Course Hours'n
else .
end) format=8.2 as ProgHours
from work.List109G4 B
group by List109G4.StudentUID, List109G4.'Initial Program'n,List109G4.Level,List109G4.CourseName) B)) format=8.2 as 'Program Hours'n
from work.List109G4
group by List109G4.StudentUID, List109G4.'Initial Program'n,List109G4.Level
order by List109G4.StudentUID, List109G4.'Initial Program'n;
quit;
LOG:
28 GOPTIONS ACCESSIBLE;
29 proc sql noprint;
30 create table List109G50 as
31 select
32 *,
33 sum(select
34 B.ProgHours
_
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.
35 from ((select
____
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.
36 List109G4.CourseName,
37 (case when not missing(List109G4.'Course Hours'n)
38 then List109G4.'Course Hours'n
39 else .
40 end) format=8.2 as ProgHours
41 from work.List109G4 B
42 group by List109G4.StudentUID, List109G4.'Initial
42 ! Program'n,List109G4.Level,List109G4.CourseName) B)) format=8.2 as 'Program Hours'n
_
22
2 The SAS System 09:30 Tuesday, June 8, 2021
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, ^=, |, ||, ~=.
43 from work.List109G4
44 group by List109G4.StudentUID, List109G4.'Initial
44 ! Program'n,List109G4.Level
45 order by List109G4.StudentUID, List109G4.'Initial Program'n;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
46 quit;
... View more