Hi there, I'm attempting to use a macro variable that is erroring out and I'm not sure why. It works fine if I manually input the individual variables which tells me it's something with my macro, but I can't figure out what it is. They're text values so they have quotes, they're separated by commas and not periods, all of my standard checks are failing to identify the problem. It's built using a query builder rather than manual programming so user error can only come into play with setting up the macro. Any help you can give is MUCH APPRECIATED. I've googled as well as searched here and haven't been able to figure anything out.
Here's where I set up the macro:
%let rptquarters = ('2019Q3','2019Q4','2020Q1','2020Q2');
Here's the log with the error:
26 PROC SQL;
27 CREATE TABLE EGTASK.WANT AS
28 SELECT t1.*
31 FROM EGTASK.HAVE t1
32 WHERE t1.FilledQuarter in (&rptquarters)
NOTE: Line generated by the macro variable "RPTQUARTERS".
32 ('2019Q3','2019Q4','2020Q1','2020Q2')
________ _
79 22
76
ERROR 79-322: Expecting a SELECT.
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.
33 GROUP BY t1.CleanedClient;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
34 QUIT;
The macro variable's content is inserted as is in the place where you call it, including the brackets. This causes SQL to expect a sub-select.
Remove the brackets in the %LET statement.
The macro variable's content is inserted as is in the place where you call it, including the brackets. This causes SQL to expect a sub-select.
Remove the brackets in the %LET statement.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.