Hello! The following code has an error. Can you help troubleshoot?
PROC SQL;
CREATE table Results AS
SELECT *
FROM ccall
WHERE (status='Reported' AND enrollment NE 0)
AND status='Not Reported' (WHERE code IN (SELECT number FROM DS));
QUIT;
I want to retain all that've reported with nonzero enrollment and all that've not reported that have codes located in a separate table named DS.... But I'm getting an error message below. Any help you can give is much appreciated! Thanks!
__________________
LOG:
73 PROC SQL;
74
75 CREATE table Results AS
76
77 SELECT *
78
79 FROM ccall
80
81 WHERE (status='Reported' AND enrollment NE 0)
82
83 AND status='Not Reported' (WHERE code IN (SELECT
-
22
76
83 ! number FROM dss));
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, *, **, +, -, /, <,
<=, <>, =, >, >=, AND, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT, HAVING,
INTERSECT, LE, LET, LT, LTT, NE, NET, NOT, OR, ORDER, OUTER, UNION, ^, ^=, |,
||, ~, ~=.
You can't have two where in the query, that should probably be an AND instead.
Also verify your brackets.
Try
PROC SQL;
CREATE table Results AS
SELECT *
FROM ccall
WHERE
status = 'Reported' AND
enrollment NE 0 AND
status = 'Not Reported' AND
code IN (SELECT number FROM DS);
QUIT;
PG
Thanks everyone!
PROC SQL;
CREATE table Results AS
SELECT *
FROM ccall
WHERE
(status = 'Reported' AND
enrollment NE 0) OR
(status = 'Not Reported' AND
code IN (SELECT number FROM DS));
QUIT;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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: