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.
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.
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.
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 .
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 !
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.