- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi I have two questions
1. How to call all macros into the session at a time.
Example: I have a folder called 'Macros' that has Two Macros ( see image )
Path of Folder location : "V:\xx6\syy\381\analysis\"
So How to call all the macros (2 ) from folder. I tried this but no luck Please let me know if I am doing wrong!
options sasautos= ('V:\xx6\syy\381\analysis\Macros', sasautos);
2. My second question is when create macros, the program name has to be the same as macro name? so that sasautos options work.
Example: my macro program name is 'chkvar.sas" but macro name is '%bign' in the program .
Thanks you for your inputs.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For autocall macros, the filename must reflect the macro name; see the relevant documentation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
All the SASAUTOS option does is assign places for SAS to look when code references a macro that has not been defined (macro code executed to compile the macro) in the current session.
Yes, the file name must be the name of the macro and the first non-comment line of the file has to have the %macro statement.
You use the macros with code in programs you are executing.
If you want to keep the file names you want then you would not use the SASAUTOS so much as program file that %includes all of the macro code and have that program, or the %include statements, execute from the Autoexec.sas.
A statement like:
%include("C:\folder\subfolder\nameoffile.sas");
will submit the code in that file to current session when encountered. You should have one %include statement for each file you want to execute. You may get away with wildcards but results may be inconsistent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%include 'V:\xx6\syy\381\analysis\Macros\*.sas' / source2;
2. If you want to use SAS autos then yes.
SASAUTOS makes macros available, not sure it actually runs them so your use case seems slightly different than the intended usage? If you want to run all these every time you start SAS you want to add that %INCLUDE line to your AUTOEXEC instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @Reeza . Please see my responses in blue.
1. Use %INCLUDE with a * wild card.
%include 'V:\xx6\syy\381\analysis\Macros\*.sas' / source2;
Response: This way I have to write 20 times with %include statement if I have 20 macro programs in the folder?
2. If you want to use SAS autos then yes.
Response: Interesting, for some reason I tried again moving programs into different folder. It was able to run the macro even though my program name different than macro name.
SASAUTOS makes macros available, not sure it actually runs them so your use case seems slightly different than the intended usage? If you want to run all these every time you start SAS you want to add that %INCLUDE line to your AUTOEXEC instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@SASuserlot wrote:
Thanks @Reeza . Please see my responses in blue.
1. Use %INCLUDE with a * wild card.
%include 'V:\xx6\syy\381\analysis\Macros\*.sas' / source2;
Response: This way I have to write 20 times with %include statement if I have 20 macro programs in the folder?
The * wildcare will run ALL programs in the folder that ends in .sas, in the order they appear which varies slightly by system. If the order matters then you should call them manually.
2. If you want to use SAS autos then yes.Response: Interesting, for some reason I tried again moving programs into different folder. It was able to run the macro even though my program name different than macro name.
SASAUTOS makes macros available, not sure it actually runs them so your use case seems slightly different than the intended usage? If you want to run all these every time you start SAS you want to add that %INCLUDE line to your AUTOEXEC instead.
That is correct. If you want use SASAUTOS then the file name must match the macro name. Simplified version of SASAUTOS, you invoke a macro, %test. It looks in that folder, in the order of folders you've declared for the test file to compile that macro. This means you can call the macro without explicilty calling the source macro code.
However, that's not what you're trying to do, so you're using the wrong tool in this case, SASAUTOS when it seems you want these run, ie executed.
SASAUTOS makes macros available for you, but doesn't actually run them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For autocall macros, the filename must reflect the macro name; see the relevant documentation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. @Kurt_Bremser @Reeza @ballardw thank you guys. all your inputs are right.