BookmarkSubscribeRSS Feed
minjeong137
Fluorite | Level 6
Sorry i'm not good at english..
please tell me what grammar is wrong.
how to fix it...
I attached a log message below.

%macro number;
%do i=20 %to 21;
proc sql;
create table work.bb_&i. as
select *
from work.dummy
where substr(num_str,5,2) =%nrbquote('&i.');
quit;
%end;
%mend number;
%number;


Log message
23 %macro number;
24 %do i=20 %to 21;
25 proc sql;
26 create table work.bb_&i. as
27 select *
28 from work.dummy
29 where substr(num_str,5,2) =%nrbquote('&i.');
30 quit;
31 %end;
32 %mend number;
33 %number;
NOTE: Line generated by the macro function "NRBQUOTE".
1 '20'
-
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.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.12 seconds
cpu time 0.04 seconds



NOTE: Line generated by the macro function "NRBQUOTE".
1 '21'
-
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.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
1 REPLY 1
ghosh
Barite | Level 11

Try


where substr(num_str,5,2) ="&i";

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 371 views
  • 0 likes
  • 2 in conversation