BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
M_Gielen
Calcite | Level 5

I am a novice using macros. I want to perform mediation analysis and want to use the PROCESS macro by A. Hayes.

While using the macro I get the error: use &data; ERROR 22-322: Expecting a name.

Line generated by the invoked macro "PROCESS".
43 use &data;

ERROR 22-322: Expecting a name.

how do I solve this?

Thanks,

Marij

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

For using SAS macros you first need to compile the macro definition. This is done by running the code that's between %macro <name of the macro>;... and %mend;

Once the macro has been compiled you can use it. You call a macro by using %<name of the macro>

 

I've downloaded the macro from https://www.processmacro.org/download.html . The code contains the macro definition AND a sample macro call.

Here the sample macro call:

%process (data=test,activate=1);

Looking into the macro definition I find:

use &data;

I assume you called the macro without providing a value for macro parameter data= and though in the code the macro variable &data resolved to nothing which then caused the error due to a USE command without any table name.

29         %process (activate=1);
NOTE: IML Ready
NOTE: Line generated by the invoked macro "PROCESS".
29                          use &data;
                                     _
                                     22
                                     76
ERROR 22-322: Expecting a name.  

 

It appears that to use this macro you need training or at least access and a read of the documentation. 

 

View solution in original post

3 REPLIES 3
Quentin
Super User

Hi,

We need more information to help.  Can you share the macro definition (i.e. the code that creates the macro)?  Can you turn on the option MPRINT, and then run your code, and post the full log starting with the macro call?

 

One possibility is that the macro has a parameter named data which you did not provide a value, or you provided an invalid value.  But there are many other possibilities.  Also be sure to start your debugging by starting with the first error (or warning) that appears in the log.  Often one problem will trigger more problems, so you always want to start with the first problem.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
PaigeMiller
Diamond | Level 26

Turn on the macro debugging option by running this line of code.

 

options mprint;

 

Then run the code again and copy the log as text and paste it into the window that appears when you click on the </> icon.

PaigeMiller_0-1663012019648.png

 

In the future, please do not show us errors without the rest of the log. Errors detached from the code that created it are not helpful.

--
Paige Miller
Patrick
Opal | Level 21

For using SAS macros you first need to compile the macro definition. This is done by running the code that's between %macro <name of the macro>;... and %mend;

Once the macro has been compiled you can use it. You call a macro by using %<name of the macro>

 

I've downloaded the macro from https://www.processmacro.org/download.html . The code contains the macro definition AND a sample macro call.

Here the sample macro call:

%process (data=test,activate=1);

Looking into the macro definition I find:

use &data;

I assume you called the macro without providing a value for macro parameter data= and though in the code the macro variable &data resolved to nothing which then caused the error due to a USE command without any table name.

29         %process (activate=1);
NOTE: IML Ready
NOTE: Line generated by the invoked macro "PROCESS".
29                          use &data;
                                     _
                                     22
                                     76
ERROR 22-322: Expecting a name.  

 

It appears that to use this macro you need training or at least access and a read of the documentation. 

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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