BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi, im new to SAS and running this sas program develop by vendor and hit error 22-322.


ERROR 22-322: syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, INPUT, PUT


The log:

NOTE 137-205: Line generated by the invoked macro "MAIN_SCORING".

      if NODENUMBER_&&SCN_&SN.._&TN. = &&NODE_N_&EN.. then do;

EAD_&&Scn_&SN.._&TN.=&&EADF_&EN.. * &&Node_L_&EN..;


the code:



%Do EN = 1 %to &EAD_Node. ;

If NODENUMBER_&&Scn_&SN.._&TN. = &&NODE_N_&EN.. then do;

EAD_&&Scn_&SN.._&TN.=&&EADF_&EN.. * &&Node_L_&EN..;

end ;

%END ;


Please help as i really no idea how to fix it! 

Super User

Rule #1 of macro development: start with working non-macro code.

Please post the original code you want to make dynamic, identify the parts which need to be dynamic or repeated, and describe from where the information for the dynamic parts come from (user input, dataset, ...).

Diamond | Level 26

Error messages without context — in other words without seeing the code the error messages refer to — are not helpful. We don't know which line of your code the error messages refer to.


So, first, please comply with @Kurt_Bremser 's request. But if you continue to get errors, we need to see the code as it appears in the log as well as the error messages. In other words, copy the ENTIRE log (not selected parts of the log) for this PROC or DATA step, and paste that into the window that appears when you click on the </> icon.



Furthermore, if your code contains macros, you need to turn on macro debugging tools by running this command before you run the macro, and then show us the ENTIRE log as described above. But again, first comply with @Kurt_Bremser's request.


options symbolgen mprint;
Paige Miller
Super User

What is the variable in this bit supposed to represent?


If that "if " statement is in a data step your macro variables are going to resolve to something like Nodenumber_<macro variable>._<Variable TN resolution>.

The dot in the middle of variable in data step is only valid with a very small number of constructs, libname.datasetname, First.byvar, Last.byvar and hash objects or java objects for Component language use. If you code is supposed to be using one of these components then you really need to describe the definitions of the objects, the data type of the objects, the values of all of those macro variables and example data.


You also have multiple places where you are ending macro variables with 2 .. such as here: &&NODE_N_&EN..

The two dots means that after the macro processor uses them the result will have a . at the end of the resolved text which is generally not a valid variable name as the . is not valid character. If the variable were to actually have a . in the name you would have to be using name literal values which mean the name is enclosed in quotes and have a trailing N:


In addition to having working non-macro code to start to debug macros you set the SAS options Mprint and possibly Symbolgen and Mlogic prior to running the code:

options mprint;

%myproblemmacro (<parameters>)

options nomprint; /* to turn of the mprint*/

Mprint will show the code actually generated by the macro so you can compare the results to your working non-macro code.

Symbolgen, which I suspect might be needed here, shows more details of how complex macro variables are built/resolved. You are using many indirect macro references, those starting with &&, and that can be very complex issue.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4 in conversation