DATA Step, Macro, Functions and more

The symbol is not recognized and will be ignored.

Reply
Frequent Contributor
Posts: 79

The symbol is not recognized and will be ignored.


I have the following piece of code.

%put &BALDT_DATE9.;

BALDT_DATE9 resolves to '22NOV2017'D

proc sql;
create table test_temp as
select * from sasd.basedata
where SESSION_DATE <= &BALDT_DATE9.
;
quit;

I am trying to subset the base dataset using the date condition. But for some reason I am keep getting the following error message.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE, USER.
ERROR 200-322: The symbol is not recognized and will be ignored.

Can some help ?

Super User
Posts: 22,850

Re: The symbol is not recognized and will be ignored.

Please post your exact code and log. 

 


dhana wrote:


I have the following piece of code.

%put &BALDT_DATE9.;

BALDT_DATE9 resolves to '22NOV2017'D

proc sql;
create table test_temp as
select * from sasd.basedata
where SESSION_DATE <= &BALDT_DATE9.
;
quit;

I am trying to subset the base dataset using the date condition. But for some reason I am keep getting the following error message.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE, USER.
ERROR 200-322: The symbol is not recognized and will be ignored.

Can some help ?


 

Frequent Contributor
Posts: 79

Re: The symbol is not recognized and will be ignored.

DATA _NULL_;
SET TEMP.LATEST_BAL_DATE;
DT3=PUT(MAX_BAL_DATE,DATE9.);
CALL SYMPUT("BALDT_DATE9",DT3);
RUN;

%LET BALDT_DATE9=%STR(%')&BALDT_DATE9.%STR(%'D);
%PUT &BALDT_DATE9.;

PROC SQL;
CREATE TABLE TEST_TEMP AS 
SELECT * FROM 
SASD.CBOL_DEP_APPLICATIONS_20171122
WHERE SESSION_DATE_AT_APPSTART <= &BALDT_DATE9.
;
QUIT;

Log:-

 

21 DATA _NULL_;
22 SET TEMP.LATEST_BAL_DATE;
23 DT3=PUT(MAX_BAL_DATE,DATE9.);
24 CALL SYMPUT("BALDT_DATE9",DT3);
25 RUN;

NOTE: There were 1 observations read from the data set TEMP.LATEST_BAL_DATE.
NOTE: DATA statement used (Total process time):
real time 0.58 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 536.00k
OS Memory 18336.00k
Timestamp 11/27/2017 11:01:22 PM
Step Count 67 Switch Count 36
Page Faults 0
Page Reclaims 92
Page Swaps 0
Voluntary Context Switches 124
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0

26
27 %LET BALDT_DATE9=%STR(%')&BALDT_DATE9.%STR(%'D);
SYMBOLGEN: Macro variable BALDT_DATE9 resolves to 22NOV2017
28 %PUT &BALDT_DATE9.;
SYMBOLGEN: Macro variable BALDT_DATE9 resolves to '22NOV2017'D
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.
'22NOV2017'D
29
30 PROC SQL;
31 CREATE TABLE TEST_TEMP AS
32 SELECT * FROM
2 The SAS System 21:18 Monday, November 27, 2017

33 SASD.CBOL_DEP_APPLICATIONS_20171122
34 WHERE SESSION_DATE_AT_APPSTART <= &BALDT_DATE9.
SYMBOLGEN: Macro variable BALDT_DATE9 resolves to '22NOV2017'D
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.
35 ;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
NOTE: Line generated by the macro variable "BALDT_DATE9".
35 '22NOV2017'D
_
22
_
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE, USER.

ERROR 200-322: The symbol is not recognized and will be ignored.

Super User
Posts: 22,850

Re: The symbol is not recognized and will be ignored.

Rather than add quotes to the macro variable use it in the code. 

 

Bal_date <= “&baldt_date9.”d;

Or use the number and don’t use a format when you create the macro variable. 

 

Also, use CALL SYMPUTX 

Super User
Super User
Posts: 7,850

Re: The symbol is not recognized and will be ignored.

[ Edited ]

If you post a log use the Insert Code button so that the forum editor doesn't messup the spacing.

 

Looks to me like you have added macro quoting to the value of macro variable.  It is confusing SAS. Remove it. 

WHERE SESSION_DATE_AT_APPSTART <= %unquote(&BALDT_DATE9.)

Why did you add the macro quoting? It is not needed.

%LET BALDT_DATE9="&BALDT_DATE9."d;

 Or just use the actual number of days.

CALL SYMPUTX("BALDT",MAX_BAL_DATE);
...
WHERE SESSION_DATE_AT_APPSTART <= &BALDT

 

Trusted Advisor
Posts: 1,288

Re: The symbol is not recognized and will be ignored.

You can solve the problem using your definition of BALDT_DATE9 by changing the where-clause to

  

WHERE SESSION_DATE_AT_APPSTART <= %unquote(&BALDT_DATE9)

 

But as a general rule I would not bother with the %STR(%') and %unquote macro functions. Instead leave BALDT_DATE9 without the quotes (i.e  BALDT_DATE9=22NOV2017).  Then whenever you want to use it as a date constant, just use "&BALDT_DATE9"D, as in

 

WHERE SESSION_DATE_AT_APPSTART <= "&BALDT_DATE9"D

 

This takes advantage of the fact that double quotes do not prevent resolution of macro expressions inside the quotes.

 

 

 

Super User
Posts: 9,574

Re: The symbol is not recognized and will be ignored.

Maim 28: macro variables need no formats:

DATA _NULL_;
DT3=PUT(today(),best.);
CALL SYMPUT("BALDT_DATE9",DT3);
RUN;

%PUT &BALDT_DATE9.;

data test;
SESSION_DATE_AT_APPSTART = today() -1;
run;

PROC SQL;
CREATE TABLE TEST_TEMP AS 
SELECT * FROM 
test
WHERE SESSION_DATE_AT_APPSTART <= &BALDT_DATE9.
;
QUIT;

For comparisons, raw values are best.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 6 replies
  • 384 views
  • 0 likes
  • 5 in conversation