If I write a macro of the sort:
%macro MyMacro(var1 /* This is first description */
,var2 /*Second Description*/);
then when using the macro, the following help text appears when calling it:
In this case, the macro and calling the macro is in the same script.
I have stored my Macros in another script, and then use a %include statement to make them available, then the help text does not appear. Is there any way to achieve this?
Edit: I am using SAS EG and using Autocall library is not an option.
Please clarify what user interface you are using that is popping up that text box.
Are you using SAS/Studio? Enterprise Guide? Something else?
Whatever your user interface is, I am not using it, so I'm not sure if my answer will work, but I think it will.
Put your macros into an AUTOCALL library instead of using %INCLUDE to access them, and then I believe you will get the desired pop-up.
I am using SAS Enterprise Guide.
Autocall I think works (have not tried) but it is not an option in this case. Any ideas?
Why is AUTOCALL not an option?
@SasStatistics wrote:
Legacy in the company I am working at.
If I have arguments against, I could change it - but currently I have not read about it so no idea. Any strong reasons why include is not preferred over autocall?
Let's suppose you have written a macro named MYMACRO. Then, each time you want to use it via %include, you have to type a command like this:
%include "/myserver/myfolder/mysubfolder/mymacro.sas";
That's a lot of typing, don't make any mistakes or your code won't run. And you have to do this in every program where you want to use the macro. And if there are multiple macros that are used, you need to type a %include for each. Lots of possibilities to make a mistake, and slower than using an AUTOCALL library.
If you use AUTOCALL, then you never have to type the above, you have to include your AUTOCALL library issuing one command in your AUTOEXEC file (you have to do this once, and never again, and not every time you want to use the macros). Then you type %mymacro (and later %mymacro2, and so on), that's a lot less typing, a lot fewer possibilities to make a mistake, and much faster.
@PaigeMiller wrote:
@SasStatistics wrote:
Legacy in the company I am working at.
If I have arguments against, I could change it - but currently I have not read about it so no idea. Any strong reasons why include is not preferred over autocall?Let's suppose you have written a macro named MYMACRO. Then, each time you want to use it via %include, you have to type a command like this:
%include "/myserver/myfolder/mysubfolder/mymacro.sas";
That's a lot of typing, don't make any mistakes or your code won't run. And you have to do this in every program where you want to use the macro. And if there are multiple macros that are used, you need to type a %include for each. Lots of possibilities to make a mistake, and slower than using an AUTOCALL library.
If you use AUTOCALL, then you never have to type the above, you have to include your AUTOCALL library issuing one command in your AUTOEXEC file (you have to do this once, and never again, and not every time you want to use the macros). Then you type %mymacro (and later %mymacro2, and so on), that's a lot less typing, a lot fewer possibilities to make a mistake, and much faster.
Adding to @PaigeMiller's comment. If everyone uses the same shared location for the Autocall library then you can share the macros by name and don't have to pass around files or filenames and paths to reference macros with %include. Though it would be a good idea to have someone in charge for what is allowed in the Autocall library.
Also, you already know that %include files do not do what you want regarding this "documentation" element.
@ballardw wrote:
@PaigeMiller wrote:
@SasStatistics wrote:
Legacy in the company I am working at.
If I have arguments against, I could change it - but currently I have not read about it so no idea. Any strong reasons why include is not preferred over autocall?Let's suppose you have written a macro named MYMACRO. Then, each time you want to use it via %include, you have to type a command like this:
%include "/myserver/myfolder/mysubfolder/mymacro.sas";
That's a lot of typing, don't make any mistakes or your code won't run. And you have to do this in every program where you want to use the macro. And if there are multiple macros that are used, you need to type a %include for each. Lots of possibilities to make a mistake, and slower than using an AUTOCALL library.
If you use AUTOCALL, then you never have to type the above, you have to include your AUTOCALL library issuing one command in your AUTOEXEC file (you have to do this once, and never again, and not every time you want to use the macros). Then you type %mymacro (and later %mymacro2, and so on), that's a lot less typing, a lot fewer possibilities to make a mistake, and much faster.
Adding to @PaigeMiller's comment. If everyone uses the same shared location for the Autocall library then you can share the macros by name and don't have to pass around files or filenames and paths to reference macros with %include. Though it would be a good idea to have someone in charge for what is allowed in the Autocall library.
Or if you are squeamish about modifying someone else's AUTOEXEC file (but you shouldn't be), or if you are remote and such modification would be difficult, you can send people one line of code, tell them to put it at the top of their programs when they want to use the AUTOCALL library, and again, no need for all that typing of %INCLUDEs. It's like magic! Don't take my word for it, @ballardw knows what he is talking about.
Hi:
Your macro program usage is not entirely clear to me. However, you should be able to use a session-compiled macro program within SAS Enterprise Guide. This example worked for me.
However, I was using &VAR1 and &VAR2 only with %PUT and in a TITLE statement. You defined VAR1 and VAR2 as positional parameters, so that's what my example used. However, that means you always need to specify your variables in that order and you do not have a good way to set defaults using positional parameters.
In "real life" I was taught to always use keyword macro program parameters instead of positional parameters because they allow for better control over the defaults of the macro variable values, as shown below:
With keyword parameters in the Macro program definition, I set defaults for both &VAR1 and &VAR2, but on invocation, only provided a value for &VAR1, which caused the macro program to use the default value for &VAR2.
Cynthia
You defined VAR1 and VAR2 as positional parameters, so that's what my example used. However, that means you always need to specify your variables in that order
Defining a macro to accept parameters by position does not prevent the user from passing them by name. In which case they can reference them in any order.
%mymacro(var2=abc,var1=xyz)
and you do not have a good way to set defaults using positional parameters.
It is not hard to add defaults in the macro code itself.
%if 0=%length(&var1) %then %let var1=default value;
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 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: