Hi I'm having trouble with the following code- specifically the subselect statements, any ideas on how to modify this?:
PROC SQL; CREATE TABLE WORK.QUERY_FOR_VVW_DWH_PTN AS SELECT t1.PlayerId, t1.FirstName, t1.LastName, t1.Email, t2.EndDate, t2.Most_Recent_Overall_Experience, t1.AdtLifetimeRange AS AdtLifetimeRange1, (SELECT t1.AdtLifetimeRange WHERE t2.EndDate <= intnx('month', today(), -6, 'e')) AS ADT6MoBack, (SELECT t1.AdtLifetimeRange WHERE t2.EndDate >= intnx('month', today(), -6, 'e')) AS ADT6MoForAS, FROM TDQT.vCXSurvey t2 INNER JOIN TDQT.vCXPlayer_SAS t1 ON (t2.PlayerId = t1.PlayerId); WHERE t2.EndDate <'20Mar2022'd; QUIT;
This is the error I get:
76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,
AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM, GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH,
LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
41 FROM TDQT.vCXSurvey t2
42 INNER JOIN TDQT.vCXPlayer_SAS t1 ON (t2.PlayerId = t1.PlayerId);
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
43 WHERE t2.EndDate <'03/20/2022'
WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.
44 QUIT;
2 The SAS System Wednesday, March 29, 2023 09:06:00 AM
45
46
47
48 %LET _CLIENTTASKLABEL=;
49 %LET _CLIENTPROCESSFLOWNAME=;
50 %LET _CLIENTPROJECTPATH=;
51 %LET _CLIENTPROJECTPATHHOST=;
52 %LET _CLIENTPROJECTNAME=;
53 %LET _SASPROGRAMFILE=;
54 %LET _SASPROGRAMFILEHOST=;
55
56 ;*';*";*/;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
76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?,
AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM, GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH,
LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
41 FROM TDQT.vCXSurvey t2
42 INNER JOIN TDQT.vCXPlayer_SAS t1 ON (t2.PlayerId = t1.PlayerId);
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
43 WHERE t2.EndDate <'03/20/2022'
WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.
44 QUIT;
2 The SAS System Wednesday, March 29, 2023 09:06:00 AM
45
46
47
48 %LET _CLIENTTASKLABEL=;
49 %LET _CLIENTPROCESSFLOWNAME=;
50 %LET _CLIENTPROJECTPATH=;
51 %LET _CLIENTPROJECTPATHHOST=;
52 %LET _CLIENTPROJECTNAME=;
53 %LET _SASPROGRAMFILE=;
54 %LET _SASPROGRAMFILEHOST=;
55
56 ;*';*";*/;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
Thanks I saw- for some reason not working still
@rrmenon wrote:
Thanks I saw- for some reason not working still
You didn't provide any of the information requested either:
Original answer:
An attempt at correcting your code, but not 100% sure as I don't know what type of SQL you're using:
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_VVW_DWH_PTN AS
SELECT t1.PlayerId,
t1.FirstName,
t1.LastName,
t1.Email,
t2.EndDate,
t2.Most_Recent_Overall_Experience,
t1.AdtLifetimeRange AS AdtLifetimeRange1,
(SELECT t1.AdtLifetimeRange WHERE t2.EndDate <= intnx('month', today(), -6, 'e')) AS ADT6MoBack,
(SELECT t1.AdtLifetimeRange WHERE t2.EndDate >= intnx('month', today(), -6, 'e')) AS ADT6MoForAS,
FROM TDQT.vCXSurvey t2
INNER JOIN TDQT.vCXPlayer_SAS t1 ON (t2.PlayerId = t1.PlayerId);
WHERE t2.EndDate <'20Mar2022'd;
QUIT;
@Reeza wrote:
I posted an answer on SO.
Many of us can't benefit from this, as we don't know what this means. Can you provide a link?
Thanks Reeza but I'm still getting the same error
HI Reeza, the sub select statements do not have a From clasue, would you mind helmping me construct this?
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_VVW_DWH_PTN AS
SELECT t1.PlayerId,
t1.FirstName,
t1.LastName,
t1.Email,
t2.EndDate,
t2.Most_Recent_Overall_Experience,
t1.AdtLifetimeRange AS AdtLifetimeRange1,
(SELECT t1.AdtLifetimeRange WHERE t2.EndDate <= intnx('month', today(), -6, 'e')) AS ADT6MoBack,
(SELECT t1.AdtLifetimeRange WHERE t2.EndDate >= intnx('month', today(), -6, 'e')) AS ADT6MoForAS,
FROM TDQT.vCXSurvey t2
INNER JOIN TDQT.vCXPlayer_SAS t1 ON (t2.PlayerId = t1.PlayerId);
WHERE t2.EndDate <'20Mar2022'd;
QUIT;
You have a surplus comma before the FROM.
You also have a wrong semicolon before the WHERE.
Also please use a code box (as you did for the code) to post the log, so we can see where the ERROR markers are placed.
And post the whole log, from the start of the procedure to the QUIT;
It's a bit hard to say where the error message comes from, but I think it is because you have a comma before FROM.
As for your "subselect" statements, they do not make sense at all. What are you trying to accomplish with those?
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 25. 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.