BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dr2014
Quartz | Level 8

Hi,

I am getting an error with the following statement. This statement is within a macro and is recalled in the later part of the code. Here is the log

%macro b;

data out.&l_datasetname.;

              ----

              22

              201

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_.

  ERROR 201-322: The option is not recognized and will be ignored


The libname out was defined as follows: libname out "&l_lib_out." ;


Based on the error , I added the quotes but I still get the message. The rest of the code in the macro has some if then and do statements which also triggers as error such as


The %IF statement is not valid in open code

But, i am not sure if the data statement is root cause of the error. Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What does &l_dataset. resolve to?  In the code which is causing you the trouble, you use out as the library, then &l_datasetname. is being resolved to what text?  Use options mlogic, mprint, symbolgen and see what the value is.  Maybe your missing a parameter to the macro, or maybe your macro variable's scope is not in that macro call, or maybe that variable is not present or invalid.  It should resolve to a valid SAS dataset name.

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What does &l_dataset. resolve to?  In the code which is causing you the trouble, you use out as the library, then &l_datasetname. is being resolved to what text?  Use options mlogic, mprint, symbolgen and see what the value is.  Maybe your missing a parameter to the macro, or maybe your macro variable's scope is not in that macro call, or maybe that variable is not present or invalid.  It should resolve to a valid SAS dataset name.

ballardw
Super User

The %IF statement is not valid in open code

Appears when the code containing %if is NOT within a %macro %mend construct. This may point to one of those statements missing or being treated incorrectly due to a number of reasons such as an unclosed quote .

dr2014
Quartz | Level 8

Hi All,

Sorry, I had commented out a few statements before and it had accidentally included the macro statement and that cause the error message. Thanks much for both your useful suggestions. @RW9 , I had used symbolgen before posting and that helped correct the syntax.

Thanks !

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1396 views
  • 3 likes
  • 3 in conversation