SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Syntax error for libname using macros

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 124
Accepted Solution

Syntax error for libname using macros

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.


Accepted Solutions
Solution
‎05-14-2015 09:33 AM
Super User
Super User
Posts: 7,991

Re: Syntax error for libname using macros

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


All Replies
Solution
‎05-14-2015 09:33 AM
Super User
Super User
Posts: 7,991

Re: Syntax error for libname using macros

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.

Super User
Posts: 11,343

Re: Syntax error for libname using macros

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 .

Frequent Contributor
Posts: 124

Re: Syntax error for libname using macros

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 !

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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