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
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.
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.
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.
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.