BookmarkSubscribeRSS Feed
Sol4
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:

&EAD_Score.;

NODENUMBER_&&&Scn_&SN.._&TN. = NODENUMBER;

%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! 

3 REPLIES 3
Kurt_Bremser
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, ...).

PaigeMiller
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.

PaigeMiller_0-1663012019648.png

 

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
ballardw
Super User

What is the variable in this bit supposed to represent?

  if NODENUMBER_&&SCN_&SN.._&TN. 

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.

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 618 views
  • 0 likes
  • 4 in conversation